Skip to main content

Python library for natural language processing

Project description

Linguistics

Linguistics is a Python library for natural language processing.

Installation

You can use pip to install linguistics.

pip install linguistics

Dependencies

Linguistics uses Abstract and Graphviz to visualize graphs of the document.

Similarity

Sentence

get_similar_pairs

from linguistics.similarity import Sentence

sentence_1 = Sentence('John Joseph Nicholson')
sentence_2 = Sentence('Nicholson, Jack')
print(sentence_1.get_similar_pairs(sentence_2))

produces:

[{'word_1': Nicholson,
  'word_2': Nicholson,
  'similarity': 1.0,
  'index_1': 2,
  'index_2': 0},
 {'word_1': John,
  'word_2': Jack,
  'similarity': 0.5,
  'index_1': 0,
  'index_2': 1},
 {'word_1': Joseph,
  'word_2': None,
  'similarity': 0,
  'index_1': 1,
  'index_2': None}]

get_unordered_similarity

print(sentence_1.get_unordered_similarity(sentence_2))
print(sentence_1.get_unordered_similarity(sentence_2, case_sensitivity=0, weights=[1, 1]))
print(sentence_1.get_unordered_similarity(sentence_2, case_sensitivity=0, weights=[2, 1]))
print(sentence_1.get_unordered_similarity(sentence_2, case_sensitivity=0, weights=[1]))
print(sentence_1.get_unordered_similarity(sentence_2, case_sensitivity=0, first_char_weight=1, weights=[1, 1]))

produces

0.5
0.75
0.8333333333333334
1.0
0.875

Document

from linguistics import Document

# create document
document = Document("He also begat and brought up five pairs of male children.")

Entity Graph

display(document.entity_graph.render())

Document Graph

display(document.graph.render())

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

linguistics-2022.5.8.tar.gz (22.9 kB view hashes)

Uploaded Source

Built Distribution

linguistics-2022.5.8-py3-none-any.whl (34.9 kB view hashes)

Uploaded Python 3

Supported by

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