DSL for building language rules
Project description
RITA DSL
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
Links
Support
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
for supporting development of this library
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rita-dsl-0.6.4.tar.gz.
File metadata
- Download URL: rita-dsl-0.6.4.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34c93c63fcfe665746c3a2fc5f5a3f6b34a2b37a078ac1ab3eeccbb73f684c34
|
|
| MD5 |
c4513922ea09197a190c3d3f76099764
|
|
| BLAKE2b-256 |
113979d74f4d338221c67d6be8adbe08b1d572516ae0bfe1f8f7556305112d5c
|
File details
Details for the file rita_dsl-0.6.4-py3-none-any.whl.
File metadata
- Download URL: rita_dsl-0.6.4-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
387d9b9fc735f94c263d12721dabcdc569c3249251800d244892fc4bb835b7e8
|
|
| MD5 |
ba60cf03cba5a8a5cac1671c6dc87a00
|
|
| BLAKE2b-256 |
48268d706b70f3c928d84422c7f55fe6da84450430368caf64cf18b11ff3dfd4
|