Skip to main content

graph builder from text

Project description

Text2Graph

🌐 Languages: 中文


📚 Table of Contents


🚀 Features

  • Build graphs from concept lists or raw text
  • Customizable sliding window size and PMI threshold
  • Returns graph data with nodes, edges, and PMI scores

🔧 Installation

pip install -e .

🧠 Usage

Build from Concept List

from text2graph.graph_builder import GraphBuilder

builder = GraphBuilder(window_size=5, pmi_threshold=0.1)
concepts = ['人工智能', '机器学习', '神经网络', '深度学习', '人工智能', '大模型', '神经网络']

nodes, edges, pmis = builder.build_graph(concepts)

Build from Text

from text2graph.graph_builder import GraphBuilder

builder = GraphBuilder(window_size=5, pmi_threshold=0.1)
text = '\n'.join(['人工智能', '机器学习', '神经网络', '深度学习', '人工智能', '大模型', '神经网络'])

data = builder.build_graph_from_text(text)
nodes = data['nodes']
edges = data['edges']
pmis = data['pmis']

📦 Output Format

  • nodes: List of unique concepts
  • edges: List of tuples (concept1, concept2)
  • pmis: List of PMI scores corresponding to each edge

✅ Testing

python -m unittest

For Developers

setup docker env

docker build -t text2graph -f docker/Dockerfile .
docker run -it --rm --name text2graph -v .\:/code text2graph bash

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

open-ttg-0.0.0.4.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

open_ttg-0.0.0.4-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file open-ttg-0.0.0.4.tar.gz.

File metadata

  • Download URL: open-ttg-0.0.0.4.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for open-ttg-0.0.0.4.tar.gz
Algorithm Hash digest
SHA256 85435038e3ecf34ed36aa67dd3920367c0b750cdd40960278e8ddb23a1a7f704
MD5 3b13102cc2a803fe63162d7170e92178
BLAKE2b-256 1668730715d4197e19b0810ab543967197a1afe58db5a8fb66d00fbffec9ae40

See more details on using hashes here.

File details

Details for the file open_ttg-0.0.0.4-py3-none-any.whl.

File metadata

  • Download URL: open_ttg-0.0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for open_ttg-0.0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e7869e0de1f2a9472b8824467510dc8f4adb5ae70a72402924cde8ca4d39b665
MD5 887d5b941eae3cf35ea8ae0e324fa3e1
BLAKE2b-256 e3ec259e84a6dcee3135ec582982979f75612d072cb7cb8b1f74610851e15ae1

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