Skip to main content

Terms Tree Library

Library to build terms tree from indented text file and to search terms in that tree.

May be used for text labeling/classification tasks.

See also: termstree library

Example

Demo Script:

import termstree

TERMS_TREE_SRC = """
# comment

Asia
    Japan
        Tokyo [url="https://en.wikipedia.org/wiki/Tokyo"]
        Osaka
    China
        Beijing
        Shanghai
Europe
    England
        London

    Germany [url="https://en.wikipedia.org/wiki/Germany"]
        Berlin
        Munich
"""

terms_tree = termstree.build(TERMS_TREE_SRC, terms_normalizer=None)

text = 'During the 16th century, Munich was a centre of the German counter reformation. Europe ...'

for hit in terms_tree.search_in(text):
    print(hit)

Result (list of 'hits' - terms found in the text):

Hit(node=Node('Munich'), dhits=1, ihits=0)
Hit(node=Node('Europe'), dhits=1, ihits=1)
Hit(node=Node('Germany', {'url': 'https://en.wikipedia.org/wiki/Germany'}), dhits=0, ihits=1)

Every hit corresponds to a term from terms tree and has next attributes:

  • node - found term
  • dhits (direct hits) - number of direct term occurrences in the text
  • ihits (indirect hits) - number of term's children occurrences

Metadata

Release files for termstree 0.2

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

Source distribution (sdist)

Source distribution for termstree 0.2
File Size Uploaded Provenance Actions
termstree-0.2.tar.gz 7.2 kB Without provenance Details for termstree-0.2.tar.gz

Release files / termstree-0.2.tar.gz

Download URL termstree-0.2.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1e4197cfb99b517e85e9644a456e368f5a0ac66a15f2670cfb17577295f4de35
BLAKE2b-256 checksum
How to use checksums
4c1b37528e404f0f48d9a2cd6c41a92e82aa6c919d2e4951d83e1c9a4845905b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for termstree 0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2 This release

1 release file No provenance

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