cdli-gh / morphology-pre-annotation-tool

Pre-annotation tool to annotate CDLI Conll files and also, validates it
0 stars 1 forks source link

-f switch. TypeError: 'map' object is not subscriptable #23

Closed khoidt closed 6 years ago

khoidt commented 6 years ago

Hi, @jayanthjaiswal. I stumbled upon the following error while running mpat -f -i:

C:\Users\Ilya\Desktop\annotation_script\helper_app>mpat -f -i C:\Users\Ilya\Desktop\annotation_script\helper_app\data\mtaac_gold_corpus\morph\processed\P113771.conll
Traceback (most recent call last):
  File "C:\Users\Ilya\AppData\Local\Programs\Python\Python36\Scripts\mpat-script.py", line 11, in <module>
    load_entry_point('cdlimpatool==0.5.3', 'console_scripts', 'mpat')()
  File "c:\users\ilya\appdata\local\programs\python\python36\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\ilya\appdata\local\programs\python\python36\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\users\ilya\appdata\local\programs\python\python36\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\ilya\appdata\local\programs\python\python36\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\users\ilya\appdata\local\programs\python\python36\lib\site-packages\cdli_mpa_tool\cli.py", line 55, in main
    check_and_process(input_path, no_output, check, format_conll, verbose)
  File "c:\users\ilya\appdata\local\programs\python\python36\lib\site-packages\cdli_mpa_tool\cli.py", line 19, in check_and_process
    formattor.process()
  File "c:\users\ilya\appdata\local\programs\python\python36\lib\site-packages\cdli_mpa_tool\format.py", line 43, in process
    self.__file_process()
  File "c:\users\ilya\appdata\local\programs\python\python36\lib\site-packages\cdli_mpa_tool\format.py", line 36, in __file_process
    line = self.__line_process(line)
  File "c:\users\ilya\appdata\local\programs\python\python36\lib\site-packages\cdli_mpa_tool\format.py", line 19, in __line_process
    line_splitted = line_splitted[:4]
TypeError: 'map' object is not subscriptable

The source .conll file (preannotated) is attached below. P113771.zip

One should mention that an output folder with a new file is being created, but the latter contains only the following text:

#new_text=P113771
# ID    FORM    SEGM    XPOSTAG HEAD    DEPREL  MISC
epageperron commented 6 years ago

This issue blocks the release of the "annotation_assistant" tool.

jayanthkmr commented 6 years ago

@khoidt @epageperron It works on my machine. This issue is due to Python version. I have added a fix now for both Python 2 and 3. Here is the input:

#new_text=P113771
# ID    FORM    SEGM    XPOSTAG HEAD    DEPREL  MISC
o.1.1   5(disz) 5(disz)[one]    NU
o.1.2   tug2    tug[textile]    N
o.1.3   usz-bar uszbar[garment][-ak]    N.GEN   uszbar[garment] N
o.2.1   6(disz) 6(disz)[one]    NU
o.2.2   tug2    tug[textile]    N
o.2.3   usz-bar uszbar[garment][-ak]    N.GEN   uszbar[garment] N
o.2.4   tur Tur[1]  FN
o.3.1   ki-la2-bi
o.3.2   3(u)    3(u)[ten]   NU
o.3.3   4(disz) 4(disz)[one]    NU
o.3.4   1/3(disz)   1/3(disz)[one]  NU
o.3.5   ma-na
o.3.6   8(disz) 8(disz)[one]    NU
o.3.7   gin2    gig[unit]   N
r.1.1   ki  ki[place]   N
r.1.2   i3-si2-na
r.2.1   ur-pa4-mu-ra
r.2.2   szu szu[hand]   N
r.2.3   ba-ti   ba[-n]-teg[accept][-ø]  MID.3-SG-H-A.V.3-SG-P   ba[-n]-szu teg[accept][-ø]  MID.3-SG-H-A.V.3-SG-P
r.3.1   iti iti[month]  N   iti[month]  N _  _ _    iti[month][-ak] N.GEN
r.3.2   ezem-{d}nin-mug
r.4.1   mu  mu[year]    N   mu[name]    N   mu[year]    N _  _ _
r.4.2   ur-bi2-lum{ki}  Urbillum[1][-ø] SN.ABS
r.4.3   ba-hul  ba-hulu[bad][-ø]    MID.V.3-SG-S    ba-hulu[bad][-ø][-ø]    MID.V.3-SG-S.ABS
s1.1.1  ur-{d}pa4-mu-ra
s1.2.1  dub-sar dubsar[scribe]  N   dubsar[scribe][-e]  N.ERG
s1.3.1  dumu    dumu[child] N
s1.3.2  ...-x

Here is the output:

#new_text=P113771
# ID    FORM    SEGM    XPOSTAG HEAD    DEPREL  MISC
o.1.1   5(disz) 5(disz)[one]    NU  _   _   _
o.1.2   tug2    tug[textile]    N   _   _   _
o.1.3   usz-bar uszbar[garment][-ak]    N.GEN   _   _   _
o.2.1   6(disz) 6(disz)[one]    NU  _   _   _
o.2.2   tug2    tug[textile]    N   _   _   _
o.2.3   usz-bar uszbar[garment][-ak]    N.GEN   _   _   _
o.2.4   tur Tur[1]  FN  _   _   _
o.3.1   ki-la2-bi   _   _   _   _   _
o.3.2   3(u)    3(u)[ten]   NU  _   _   _
o.3.3   4(disz) 4(disz)[one]    NU  _   _   _
o.3.4   1/3(disz)   1/3(disz)[one]  NU  _   _   _
o.3.5   ma-na   _   _   _   _   _
o.3.6   8(disz) 8(disz)[one]    NU  _   _   _
o.3.7   gin2    gig[unit]   N   _   _   _
r.1.1   ki  ki[place]   N   _   _   _
r.1.2   i3-si2-na   _   _   _   _   _
r.2.1   ur-pa4-mu-ra    _   _   _   _   _
r.2.2   szu szu[hand]   N   _   _   _
r.2.3   ba-ti   ba[-n]-teg[accept][-ø]  MID.3-SG-H-A.V.3-SG-P   _   _   _
r.3.1   iti iti[month]  N   _   _   _
r.3.2   ezem-{d}nin-mug _   _   _   _   _
r.4.1   mu  mu[year]    N   _   _   _
r.4.2   ur-bi2-lum{ki}  Urbillum[1][-ø] SN.ABS  _   _   _
r.4.3   ba-hul  ba-hulu[bad][-ø]    MID.V.3-SG-S    _   _   _
s1.1.1  ur-{d}pa4-mu-ra _   _   _   _   _
s1.2.1  dub-sar dubsar[scribe]  N   _   _   _
s1.3.1  dumu    dumu[child] N   _   _   _
s1.3.2  ...-x   _   _   _   _   _
epageperron commented 6 years ago

Works for me too. @khoidt can you try it again? Make sure the tool is up to date

jayanthkmr commented 6 years ago

Your Python Environment

epageperron commented 6 years ago

If I can run it, then it's not his python environment 'cause mine is messier than on that image :-)

( @nomoon see this? :D )

khoidt commented 6 years ago

@jayanthjaiswal, @epageperron, thank you a lot, it works! I'm closing this issue.

jayanthkmr commented 6 years ago

@epageperron @khoidt One thing I notice in the formatter tool is that it will remove all extra columns annotations after the first 4 columns. I know the issue is closed but don't want to create an issue as it was by design and requirement. Is this behaviour of tool ok?

epageperron commented 6 years ago

Do you have another proposition on how to delete suggestions for alternate analyses? I don't see other ways.

jayanthkmr commented 6 years ago

Sorry my bad. I thought they were the annotations for other column heads (HEAD DEPREL MISC). i always think that the single annotator of conll will do it all at the same time.