DeanLight / spannerlib

https://deanlight.github.io/spannerlib/
Apache License 2.0
3 stars 1 forks source link

how to spannerfy simple python code #88

Open DeanLight opened 1 year ago

DeanLight commented 1 year ago

stam.txt

DeanLight commented 1 year ago
# literal="ards",
# category="associated_diagnosis",
# pattern=[
#     {"LOWER": "ards"},
#     {"LOWER": "(", "OP": "?"},
#     {"LOWER": {"REGEX": "[12]/2"}},
#     {"LOWER": ")", "OP": "?"},
# ],

#  pattern=[
#                 {"LOWER": "results"},
#                 {"LEMMA": "be", "OP": "?"},
#                 {"LOWER": {"IN": ["pos", "positive"]}},
#             ],

# pattern=[
#         {
#             "POS": {"IN": ["NOUN", "PROPN", "PRON"]},
#             "LOWER": {
#                 "IN": [
#                     "wife",
#                     "husband",
#                     "spouse",
#                     "family",
#                     "member",
#                     "girlfriend",
#                     "

texts = [ # annotation, text
    ('raw text','report was bad'),
    ('lemmatized','report be bad'),
    ('pos','report<NOUN> be<AUX> bad<ADJ>'),
]

rules = [ # regex annotation
    ('ards\(?[12]/2\)?','raw text'),
    ('results(be)?(pos|positive)','lemma'),
    ('((wife)|(husband))<(NOUN|PROPN|PRON)>','pos')
]

%rgxlog

matched_labels(Label,Match)<- rules(Regex,Ann,Label), texts(Ann,Text) ,\
        regex(Regex,Text)->(Match)
doc_labels(Label)<- matched_labels(Label,Match)

rgx=(ards:LABEL=good,POS=NOUN)