udapi / udapi-python

Python framework for processing Universal Dependencies data
GNU General Public License v3.0
57 stars 31 forks source link

FixPunct throws an exception on () #90

Closed dan-zeman closed 3 years ago

dan-zeman commented 3 years ago

Minimal example:

# sent_id = mst-1835
# text = Yukarıda önerdiğim ölçüte bilimsel Ölçüt () adını veriyorum.
1   Yukarıda    yukarı  ADJ NAdj    Case=Loc|Number=Sing|Person=3   2   amod    _   _
2   önerdiğim   öner    VERB    Verb    Aspect=Perf|Mood=Ind|Number[psor]=Sing|Person[psor]=1|Polarity=Pos|Tense=Past|VerbForm=Part 3   acl _   _
3   ölçüte  ölçüt   NOUN    Noun    Case=Dat|Number=Sing|Person=3   9   obl _   _
4   bilimsel    bilimsel    ADJ Adj _   5   amod    _   _
5   Ölçüt   ölçüt   NOUN    Noun    Case=Nom|Number=Sing|Person=3   8   nmod:poss   _   _
6   (   (   PUNCT   Punc    _   7   punct   _   SpaceAfter=No
7   )   )   PUNCT   Punc    _   9   punct   _   _
8   adını   ad  NOUN    Noun    Case=Acc|Number=Sing|Number[psor]=Sing|Person=3|Person[psor]=3  9   obj _   _
9   veriyorum   ver VERB    Verb    Aspect=Prog|Mood=Ind|Number=Sing|Person=1|Polarity=Pos|Polite=Infm|Tense=Pres   0   root    _   SpaceAfter=No
10  .   .   PUNCT   Punc    _   9   punct   _   _

Save it as pokus.conllu, and run:

python udapy -s ud.FixPunct < pokus.conllu

Result:

2021-05-02 12:17:40,901 [   INFO] execute - No reader specified, using read.Conllu
2021-05-02 12:17:40,901 [   INFO] execute -  ---- ROUND ----
2021-05-02 12:17:40,901 [   INFO] execute - Executing block Conllu
2021-05-02 12:17:40,903 [   INFO] execute - Executing block FixPunct
Traceback (most recent call last):
  File "C:\Users\Dan\Documents\Lingvistika\Nástroje\udapi-python\bin\udapy", line 114, in 
    runner.execute()
  File "C:\Users\Dan\Documents\Lingvistika\Nástroje\udapi-python\udapi\core\run.py", line 159, in execute
    block.apply_on_document(document)
  File "C:\Users\Dan\Documents\Lingvistika\Nástroje\udapi-python\udapi\core\block.py", line 48, in apply_on_document
    self.process_document(document)
  File "C:\Users\Dan\Documents\Lingvistika\Nástroje\udapi-python\udapi\core\block.py", line 56, in process_document
    self.process_bundle(bundle)
  File "C:\Users\Dan\Documents\Lingvistika\Nástroje\udapi-python\udapi\core\block.py", line 39, in process_bundle
    self.process_tree(tree)
  File "C:\Users\Dan\Documents\Lingvistika\Nástroje\udapi-python\udapi\block\ud\fixpunct.py", line 82, in process_tree
    self._fix_paired_punct(root, node, closing_punct)
  File "C:\Users\Dan\Documents\Lingvistika\Nástroje\udapi-python\udapi\block\ud\fixpunct.py", line 216, in _fix_paired_punct
    self._fix_pair(root, opening_node, node)
  File "C:\Users\Dan\Documents\Lingvistika\Nástroje\udapi-python\udapi\block\ud\fixpunct.py", line 258, in _fix_pair
    closing_node.parent = closing_node.prev_node
  File "C:\Users\Dan\Documents\Lingvistika\Nástroje\udapi-python\udapi\core\node.py", line 322, in parent
    raise CycleError('Setting the parent of %s to %s would lead to a cycle.', self, new_parent)
udapi.core.node.CycleError: Setting the parent of <mst-1835#7, )> to <mst-1835#6, (> would lead to a cycle.
martinpopel commented 3 years ago

Thanks for reporting. It should be fixed now.