Skip to main content

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

Release files for open-ttg 0.0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for open-ttg 0.0.0.4
File Size Uploaded
open-ttg-0.0.0.4.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for open-ttg 0.0.0.4
File Interpreter ABI Platform
open_ttg-0.0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 12.2 kB

Release files / open-ttg-0.0.0.4.tar.gz

Download URL open-ttg-0.0.0.4.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
85435038e3ecf34ed36aa67dd3920367c0b750cdd40960278e8ddb23a1a7f704
BLAKE2b-256 checksum
How to use checksums
1668730715d4197e19b0810ab543967197a1afe58db5a8fb66d00fbffec9ae40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release files / open_ttg-0.0.0.4-py3-none-any.whl

Download URL open_ttg-0.0.0.4-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7869e0de1f2a9472b8824467510dc8f4adb5ae70a72402924cde8ca4d39b665
BLAKE2b-256 checksum
How to use checksums
e3ec259e84a6dcee3135ec582982979f75612d072cb7cb8b1f74610851e15ae1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release history Release notifications | RSS feed

This release

0.0.0.4 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page