Skip to main content

DSL for building language rules

Project description

RITA DSL

Documentation Status codecov made-with-python Maintenance PyPI version fury.io PyPI download month GitHub license

This is a language, loosely based on language Apache UIMA RUTA, focused on writing manual language rules, which compiles into either spaCy compatible patterns, or pure regex. These patterns can be used for doing manual NER as well as used in other processes, like retokenizing and pure matching

An Introduction Video

Intro

Links

Support

reddit Gitter

Install

pip install rita-dsl

Simple Rules example

rules = """
cuts = {"fitted", "wide-cut"}
lengths = {"short", "long", "calf-length", "knee-length"}
fabric_types = {"soft", "airy", "crinkled"}
fabrics = {"velour", "chiffon", "knit", "woven", "stretch"}

{IN_LIST(cuts)?, IN_LIST(lengths), WORD("dress")}->MARK("DRESS_TYPE")
{IN_LIST(lengths), IN_LIST(cuts), WORD("dress")}->MARK("DRESS_TYPE")
{IN_LIST(fabric_types)?, IN_LIST(fabrics)}->MARK("DRESS_FABRIC")
"""

Loading in spaCy

import spacy
from rita.shortcuts import setup_spacy


nlp = spacy.load("en")
setup_spacy(nlp, rules_string=rules)

And using it:

>>> r = nlp("She was wearing a short wide-cut dress")
>>> [{"label": e.label_, "text": e.text} for e in r.ents]
[{'label': 'DRESS_TYPE', 'text': 'short wide-cut dress'}]

Loading using Regex (standalone)

import rita

patterns = rita.compile_string(rules, use_engine="standalone")

And using it:

>>> list(patterns.execute("She was wearing a short wide-cut dress"))
[{'end': 38, 'label': 'DRESS_TYPE', 'start': 18, 'text': 'short wide-cut dress'}]

Special Thank You

Special thanks goes to

JetBrains

for supporting development of this library

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

rita-dsl-0.6.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rita_dsl-0.6.0-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file rita-dsl-0.6.0.tar.gz.

File metadata

  • Download URL: rita-dsl-0.6.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.6.9 Linux/5.3.0-1034-azure

File hashes

Hashes for rita-dsl-0.6.0.tar.gz
Algorithm Hash digest
SHA256 6c212c436b2d3ad73ee52b4a2af4c3f2bddbb03d0b8c0ec21a0e49b094614159
MD5 711c8fa1a17c6820a3a741a5f503adcf
BLAKE2b-256 777865e9bb03806304f22e4f6051f820a81c0b9a5c73f13acbec801c4d2b1450

See more details on using hashes here.

File details

Details for the file rita_dsl-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: rita_dsl-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.6.9 Linux/5.3.0-1034-azure

File hashes

Hashes for rita_dsl-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86f3ffcee32a8c2c715f5ace9cdaed5e560f60c6312b9dc0f1ca1cdefc40db3c
MD5 9b9d391123c0483c6cdbb846418f1dc6
BLAKE2b-256 3fb9d1730df7ff8738e18d2dd342e9e31df6a9a455b4ddc9bc52b14ace24f4c7

See more details on using hashes here.

Supported by

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