natasha / yargy

Rule-based facts extraction for Russian language
MIT License
315 stars 40 forks source link

AttributeError: 'MorphPipelineScheme' object has no attribute 'keys' #85

Open tonal opened 1 year ago

tonal commented 1 year ago

from .grammars.addr import ADDR_PART

for li in ADDR_PART.normalized.as_bnf.source:
    print(li, file=out)

Error:

Traceback (most recent call last):
  File "/home/tonal/lang/projects/promsoft/ml/ner/ner-kadastr/get_addr_nat.py", line 83, in <module>
    main()
  File "/home/tonal/lang/projects/promsoft/ml/ner/ner-kadastr/get_addr_nat.py", line 29, in main
    for li in ADDR_PART.normalized.as_bnf.source:
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/constructors.py", line 130, in as_bnf
    return self.transform(
           ^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/constructors.py", line 96, in transform
    return TransformatorsComposition(transformators)(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/visitor.py", line 28, in __call__
    item = transformator()(item)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/bnf.py", line 100, in __call__
    return super(BNFTransformator, self).__call__(root)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 66, in __call__
    return self.visit(root)
           ^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 73, in visit
    item = self.resolve_method(item)(item)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/bnf.py", line 135, in visit_InterpretationRule
    item = self.visit_WrapperRule(item)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/bnf.py", line 120, in visit_WrapperRule
    item = self.visit(item)
           ^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 73, in visit
    item = self.resolve_method(item)(item)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/bnf.py", line 135, in visit_InterpretationRule
    item = self.visit_WrapperRule(item)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/bnf.py", line 120, in visit_WrapperRule
    item = self.visit(item)
           ^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 73, in visit
    item = self.resolve_method(item)(item)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/bnf.py", line 113, in visit_Rule
    return BNFRule([self.visit(_) for _ in item.productions])
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/bnf.py", line 113, in <listcomp>
    return BNFRule([self.visit(_) for _ in item.productions])
                    ^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 73, in visit
    item = self.resolve_method(item)(item)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 85, in visit_Production
    [self.visit_term(_) for _ in item.terms],
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 85, in <listcomp>
    [self.visit_term(_) for _ in item.terms],
     ^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 79, in visit_term
    return self.visit(item)
           ^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 73, in visit
    item = self.resolve_method(item)(item)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/bnf.py", line 135, in visit_InterpretationRule
    item = self.visit_WrapperRule(item)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/bnf.py", line 120, in visit_WrapperRule
    item = self.visit(item)
           ^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 73, in visit
    item = self.resolve_method(item)(item)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/bnf.py", line 113, in visit_Rule
    return BNFRule([self.visit(_) for _ in item.productions])
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/bnf.py", line 113, in <listcomp>
    return BNFRule([self.visit(_) for _ in item.productions])
                    ^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 73, in visit
    item = self.resolve_method(item)(item)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 85, in visit_Production
    [self.visit_term(_) for _ in item.terms],
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 85, in <listcomp>
    [self.visit_term(_) for _ in item.terms],
     ^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 79, in visit_term
    return self.visit(item)
           ^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 73, in visit
    item = self.resolve_method(item)(item)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/bnf.py", line 135, in visit_InterpretationRule
    item = self.visit_WrapperRule(item)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/bnf.py", line 120, in visit_WrapperRule
    item = self.visit(item)
           ^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 73, in visit
    item = self.resolve_method(item)(item)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/bnf.py", line 113, in visit_Rule
    return BNFRule([self.visit(_) for _ in item.productions])
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/bnf.py", line 113, in <listcomp>
    return BNFRule([self.visit(_) for _ in item.productions])
                    ^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 73, in visit
    item = self.resolve_method(item)(item)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 85, in visit_Production
    [self.visit_term(_) for _ in item.terms],
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 85, in <listcomp>
    [self.visit_term(_) for _ in item.terms],
     ^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 79, in visit_term
    return self.visit(item)
           ^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/transformators.py", line 73, in visit
    item = self.resolve_method(item)(item)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/rule/bnf.py", line 150, in visit_PipelineRule
    return item.pipeline.as_bnf
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/pipelines.py", line 116, in as_bnf
    return self.bnf(self.productions)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/pipelines.py", line 20, in __init__
    productions = list(productions)
                  ^^^^^^^^^^^^^^^^^
  File "/home/tonal/.pyenv/versions/ner-kadastr/lib/python3.11/site-packages/yargy/pipelines.py", line 108, in productions
    for key in self.keys:
               ^^^^^^^^^
AttributeError: 'MorphPipelineScheme' object has no attribute 'keys'