Skip to main content

AI/NLP (Spacy) Rule Based Matcher pattern finder

Project description

PatternOmatic 0.2.*

#AI · #EvolutionaryComputation · #NLP

Built with spaCy License: LGPL v3 Build Status Sonar Coverage Duplicated Lines (%) Maintainability Rating GitHub repo size SourceRank PyPI - Downloads PyPI version

Discover spaCy's linguistic patterns matching a given set of string samples


Basic usage

From sources

Clone SCM official repository

git clone

Play with Makefile

  • make venv to activate project's Virtual Environment*
  • make libs to install dependencies
  • make test to run Unit Tests
  • make coverage to run Code Coverage
  • make run to run PatternOmatic's script with example parameters

* you must have one first

From package

Install package

pip install PatternOmatic

Play with the CLI

# Show help -h

# Usage example 1: Basic -s Hello world -s Goodbye world

# Usage example 2: Using a different language
python -m spacy download es_core_news_sm -s Me llamo Miguel -s Se llama PatternOmatic -l es_core_news_sm

Play with the library

PatternOmatic library client example.
Find linguistic patterns to be used by the spaCy Rule Based Matcher

from PatternOmatic.api import find_patterns, Config

if __name__ == '__main__':

    my_samples = ['I am a cat!', 'You are a dog!', 'She is an owl!']

    # Optionally, let it evolve a little bit more!
    config = Config()
    config.max_generations = 150
    config.max_runs = 3

    patterns_found, _ = find_patterns(my_samples)

    print(f'Patterns found: {patterns_found}')



✅ No OS dependencies, no storage or database required!

✅ Lightweight package with just a little direct pip dependencies

✅ Easy and highly configurable to boost clever searches

✅ Includes basic logging mechanism

✅ Includes basic reporting, JSON and CSV format supported. Report file path is configurable

✅ Configuration file example provided (config.ini)

✅ Default configuration is run if no configuration file provided

✅ Provides rollback actions against several possible misconfiguration scenarios


✅ Basic Evolutionary (Grammatical Evolution) parameters available and configurable

✅ Supports two different Evolutionary Fitness functions

✅ Supports Binary Tournament Evolutionary Selection Type

✅ Supports Random One Point Crossover Evolutionary Recombination Type

✅ Supports "µ + λ" Evolutionary Replacement Type

✅ Supports "µ ∪ λ" with elitism Evolutionary Replacement Type

✅ Supports "µ ∪ λ" without elitism Evolutionary Replacement Type

✅ Typical evolutionary performance metrics included:

  • Success Rate (SR)
  • Mean Best Fitness (MBF)
  • Average Evaluations to Solution (AES)


Compatible with any spaCy Language Model

Supports all spaCy's Rule Based Matcher standard Token attributes

Supports the following spaCy's Rule Based Matcher non standard Token attributes (via underscore)

  • ent_id
  • ent_iob
  • ent_kb_id
  • has_vector
  • is_bracket
  • is_currency
  • is_left_punct
  • is_oov
  • is_quote
  • is_right_punct
  • lang
  • norm
  • prefix
  • sentiment
  • string
  • suffix
  • text_with_ws
  • whitespace

✅ Supports skipping boolean Token attributes

Supports spaCy's Rule Based Matcher Extended Pattern Syntax

Supports spaCy's Rule Based Matcher Grammar Operators and Quantifiers

Supports Token Wildcard

✅ Supports defining the number of attributes per token within searched patterns

✅ Supports usage of non repeated token attribute values

Author: Miguel Revuelta Espinosa (revuel), a humble AI enthusiastic

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

PatternOmatic-0.2.3.tar.gz (28.6 kB view hashes)

Uploaded source

Built Distribution

PatternOmatic-0.2.3-py3-none-any.whl (56.4 kB view hashes)

Uploaded py3

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