Skip to main content

DSL for building language rules

Project description

Rita Logo

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'}]

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.7.4.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

rita_dsl-0.7.4-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rita-dsl-0.7.4.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.9.7 Linux/5.11.0-1020-azure

File hashes

Hashes for rita-dsl-0.7.4.tar.gz
Algorithm Hash digest
SHA256 d62e1ad6eab16dfd357480deb816240e23c8bb5e20ed8b15896e639ff09522dc
MD5 d7c9d9f0888c0e0aa30ce0e7df772fce
BLAKE2b-256 570223f3c8717ce24ca373b448165c743ea314832f1f8fa1533e939f11b4c3ef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rita_dsl-0.7.4-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.9.7 Linux/5.11.0-1020-azure

File hashes

Hashes for rita_dsl-0.7.4-py3-none-any.whl
Algorithm Hash digest
SHA256 512073ec8af8b81f3d9051947843175e0f843693de30e0fd2a8aaa577f15a0f6
MD5 19b3e1a22d19588bdfcbc35cc3e03018
BLAKE2b-256 6e3395e72ed7a7515d10e6dce206e15ca7828c77667285f9ff63de3d4b34b37a

See more details on using hashes here.

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