Skip to main content

An integration package connecting Jieba and LangChain

Project description

langchain-jieba

An integration package connecting Jieba and LangChain

Jieba link extractor

Description

langchain_community.graph_vectorstores support storing texts and their relationships in a vector database in the form of a knowledge graph.But the recommended extractor such as KeybertLinkExtractor works better in an English environment,while it performs poorly in a Chinese environment. JiebaLinkExtractor extract keywords from texts depend on jieba.analyse lib, which more suitable in a Chinese environment.

Installation

%pip install langchain_jieba

Usage

extract from single text

from langchain_jieba import JiebaLinkExtractor

extractor = JiebaLinkExtractor()
results = extractor.extract_one("小明硕士毕业于中国科学院计算所,后在日本京都大学深造")
print(f"results={results}")

results={Link(kind='kw', direction='bidir', tag='日本京都大学'), Link(kind='kw', direction='bidir', tag='计算所'), Link(kind='kw', direction='bidir', tag='小明')}

extract from multiple texts

from langchain_jieba import JiebaLinkExtractor

CONTENT1 = '小明硕士毕业于中国科学院计算所,后在日本京都大学深造'
CONTENT2 = '我来到北京清华大学'
extractor = JiebaLinkExtractor()
results = list(extractor.extract_many([CONTENT1, CONTENT2]))
print(f"results[0]={results[0]}")
print(f"results[1]={results[1]}")

results[0]={Link(kind='kw', direction='bidir', tag='日本京都大学'), Link(kind='kw', direction='bidir', tag='计算所'), Link(kind='kw', direction='bidir', tag='小明')} results[1]={Link(kind='kw', direction='bidir', tag='清华大学'), Link(kind='kw', direction='bidir', tag='来到'), Link(kind='kw', direction='bidir', tag='北京')}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_jieba-0.1.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_jieba-0.1.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file langchain_jieba-0.1.1.tar.gz.

File metadata

  • Download URL: langchain_jieba-0.1.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.11.11 Windows/10

File hashes

Hashes for langchain_jieba-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d996a0992d6d7f9a85231ea0d814960fb48cf8fd4742e33980f2204fc835a06e
MD5 fe45be017be36cb315d7fc64ea6e5695
BLAKE2b-256 5d66eb1f1bb2195489dd1dc6e2813f7e54ef7d831a33bad3a604d17718684112

See more details on using hashes here.

File details

Details for the file langchain_jieba-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: langchain_jieba-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.11.11 Windows/10

File hashes

Hashes for langchain_jieba-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c65bb14450d5f17918da86a0fdaf6fbd9bfbea3348a8da0aa9c07637b7b5b9b8
MD5 83f85ac3c816ab1df74fdfb69dd4b5e5
BLAKE2b-256 7b8b7c514bcd04857e4affce9f7e8e21b7ec80d2592a858f924e64f4152d7358

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page