Skip to main content

LingPatLab

PyPI version Downloads Python 3.10+ License: MIT Code style: autopep8 spaCy

Linguistic Pattern Laboratory: Advanced NLP pipeline for text analysis, entity extraction, and pattern recognition.

Features

  • Tokenization: Custom Graffl tokenizer with intelligent handling of contractions, abbreviations, and punctuation
  • Parsing: Deep linguistic analysis with POS tagging, dependency parsing, and WordNet integration
  • Entity Extraction: Pattern-based extraction of people and topics with anaphora resolution
  • Segmentation: Paragraph and sentence boundary detection
  • Rich Annotations: Sentiment, lemmatization, stemming, and morphological features

Installation

pip install lingpatlab

Quick Start

from lingpatlab import LingPatLab

api = LingPatLab()

# Parse text into structured tokens
sentence = api.parse_input_text("Admiral Nimitz commanded the Pacific Fleet.")
print(sentence.to_string())

# Extract people with anaphora resolution
text = "Admiral William Halsey led the fleet. Halsey was known for his aggressive tactics."
sentence = api.parse_input_text(text)
people = api.extract_people(sentence)
# Returns: {'Halsey': ['Admiral William Halsey', 'Halsey']}

# Extract topics and named entities
topics = api.extract_topics(sentence)

Usage Examples

Parse Multiple Lines

lines = [
    "The Battle of Midway was a turning point.",
    "Admiral Nimitz made crucial decisions."
]
sentences = api.parse_input_lines(lines)

for sentence in sentences:
    print(sentence.to_string())

Segmentation

from lingpatlab import segment_input_text

text = "First sentence. Second sentence. Third sentence."
segments = segment_input_text(text)
# Returns: ['First sentence.', 'Second sentence.', 'Third sentence.']

Access Token Details

sentence = api.parse_input_text("The quick brown fox jumps.")

for token in sentence:
    print(f"Text: {token.text}")
    print(f"POS: {token.pos}")
    print(f"Lemma: {token.normal}")
    print(f"Is WordNet: {token.is_wordnet}")
    print(f"Dependency: {token.dep}")

Data Classes

  • Sentence: Single sentence with token list
  • Sentences: Collection of sentences
  • SpacyResult: Individual token with full linguistic annotation
  • OtherInfo: Additional morphological and dependency metadata

Architecture

LingPatLab
├── tokenizer/     # Custom tokenization with Graffl
├── parser/        # spaCy integration + enhancements
├── analyzer/      # Entity extraction with pattern matching
├── segmenter/     # Sentence and paragraph segmentation
└── utils/         # WordNet, Porter stemmer, utilities

Requirements

  • Python 3.10+
  • spaCy 3.8.2
  • spaCy model: en_core_web_sm

Development

# Install with dev dependencies
pip install -e ".[linting,testing]"

# Run tests
pytest

# Run regression suite
python regression/regression_runner.py

License

MIT License - see LICENSE for details.

Author

Craig Trim - craigtrim@gmail.com

More NLP articles and demos at craigtrim.com

Metadata

Release files for lingpatlab 1.1.1

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

Source distribution (sdist)

Source distribution for lingpatlab 1.1.1
File Size Uploaded
lingpatlab-1.1.1.tar.gz 49.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lingpatlab 1.1.1
File Interpreter ABI Platform
lingpatlab-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 122.8 kB

Release files / lingpatlab-1.1.1.tar.gz

Download URL lingpatlab-1.1.1.tar.gz
Size 49.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5e5d719bd742243ffe726bf9090a1950d67cbc595d2ab2d6d03151140dc783e2
BLAKE2b-256 checksum
How to use checksums
5073f2833911de27b52790e26bedda3b7b4be0ec20dbf245961c5bd63ecc0064
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.11.9 Darwin/24.6.0

Release files / lingpatlab-1.1.1-py3-none-any.whl

Download URL lingpatlab-1.1.1-py3-none-any.whl
Size 73.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c7e3a552a0e63679d9b9ec9fb7602edea8ef51fd94cb97a020c65c21218d175e
BLAKE2b-256 checksum
How to use checksums
3ef80515b6b3ba9be2ed766245a209f0e7f97176450d07cb1edd0a5964e2915b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.11.9 Darwin/24.6.0

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.0.0

2 release files

0.2.13

2 release files

0.2.11

2 release files

0.2.10

2 release files

0.1.16

2 release files

0.1.14

2 release files

0.1.12

2 release files

0.1.10

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