OpenCCG / openccg

OpenCCG library for parsing and realization with CCG
http://openccg.sourceforge.net/
Other
205 stars 45 forks source link

most tabs in ccg-editor.py are empty #16

Closed shoeffner closed 5 years ago

shoeffner commented 6 years ago

I am running ccg-editor.py using python 2.7.15. As explained in #1, I compiled OpenCCG from source using ccg-build inside the root directory, so that ccg2xml is properly created inside the bin directory.

My call is

ccg-editor.py /path/to/grammar.xml

The grammar I am using can be found at https://www.sfbtr8.spatial-cognition.de/en/project/interaction/i5-diaspace/resources/index.html (english.zip).

First, the lex.py fails because the inputs are of type unicode instead of types.StringType. Changing the type check to

if not isinstance(s, (types.StringType, unicode)):
    raise ValueError, "Expected a string"

fixes this partly. Alternatively I tried to encode the string if it is of type unicode, but in principle it doesn't seem to matter much.

Additionally, the call to ccg2xml.draw_parse does not work with the generated version. I changed the call to

ccg2xml.draw_parse(self.cfile.curparse.parse, self.cfile, self.child, self.vars, self.child, self)

which does not work (but at least throws no errors anymore). I also tried to create a new canvas element to pass this as the second last argument, without success (maybe some parameters were wrong...). visccg seems to have the exact same problems, as it also uses a similar (or the same?) GUI.

Do you think it is possible to get the editor up and running somehow? Or are you aware of any other tools which one could use to edit the grammars a little bit more comfortably?

edit: To be clear, the file provided to the ccg-editor.py is properly shown (though it contains some non-ascii character placeholders, so the encoding issue might go deeper than that), but for example clicking on the "lexicon"-tab leaves me with a non-existent content part of the tab window.

dmhowcroft commented 6 years ago

Hi Sebastian,

I replicate all of your reported errors when running with 2.7.15 on Fedora 29. If I recall correctly, the ccg-editor.py program has been broken in this way for about as long as I have been using OpenCCG (since about 2013).

I haven't tried installing Python 2.4 or 2.5, which appear to have been current at the time Ben Wing wrote the original code (in about 2006), but I am not convinced that that would solve these issues either.

Sorry I can't be more helpful at this time :/

mwhite14850 commented 6 years ago

Hi Sebastian and Dave

I don't think there's been much effort on building handcrafted grammars since Jason Baldridge left U Texas; instead there's been more effort on deriving grammars from corpora.

At this point, I think the most sensible thing might be to put up a notice/warning about the status of ccg-editor.py. Where would be the best place to put this?

Thanks Mike

On Wed, Nov 14, 2018 at 7:37 AM Dave H notifications@github.com wrote:

Hi Sebastian,

I replicate all of your reported errors when running with 2.7.15 on Fedora

  1. If I recall correctly, the ccg-editor.py program has been broken in this way for about as long as I have been using OpenCCG (since about 2013).

I haven't tried installing Python 2.4 or 2.5, which appear to have been current at the time Ben Wing wrote the original code (in about 2006), but I am not convinced that that would solve these issues either.

Sorry I can't be more helpful at this time :/

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/OpenCCG/openccg/issues/16#issuecomment-438706015, or mute the thread https://github.com/notifications/unsubscribe-auth/ADxvzUuH-c5xKeDivndnzob8Hxa2BCXVks5uvDjCgaJpZM4YcDMu .

dmhowcroft commented 6 years ago

@shoeffner, I just realized the basic problem: we're supposed to open .ccg files with this editor, not grammar.xml (and other XML) files. Try it with the tiny.ccg file I've attached to this post. (Just rename it to tiny.ccg; I had to add .txt for GitHub to let me upload it.)

tiny.ccg.txt

shoeffner commented 6 years ago

Nice, the tiny.ccg can be loaded after applying this change discussed above:

if not isinstance(s, (types.StringType, unicode)):
    raise ValueError, "Expected a string"

The draw call seems to work fine, here you can see me changing the 3rd person to 2nd person:

image

Thank you very much, @dmhowcroft and @mwhite14850 , this helped a lot.

Some button press threw this error, but I was able to edit the lexicon and save/restore it properly.

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1550, in __call__
    return self.func(*args)
  File "/openccg/bin/ccg2xml.py", line 2556, in <lambda>
    self.mainFrame))
  File "/openccg/bin/ccg2xml.py", line 2621, in saveSection
    cfile.setAllText(self.text.get(1.0,END))
AttributeError: 'NoneType' object has no attribute 'get'

Now, @mwhite14850, since the editor seems to be kind-of-working if that little patch is applied, there is probably no serious action needed to warn about it – I can just provide you with a PR for the fix if you want? Still, a warning inside the README that some of the included tools might no longer work due to software compatibility issues or something could be an idea.

@dmhowcroft Now I just need to find out how to use *.ccg files with OpenCCG and how to generate them from our grammar files, is there a tool already included in OpenCCG?

dmhowcroft commented 6 years ago

@dmhowcroft Now I just need to find out how to use *.ccg files with OpenCCG and how to generate them from our grammar files, is there a tool already included in OpenCCG?

@shoeffner, unfortunately I don't see any code for xml2ccg conversion in ccg2xml.py or elsewhere, though such a tool would definitely be helpful. If you need to put one together, I would start from looking at the parts of ccg2xml.py which assemble the XML for output and work from there backwards to reverse the process. If you end up doing this, please let us know and do submit a pull request so we can incorporate it into the larger project :)

shoeffner commented 6 years ago

Thank you. I'll see what I can do, because we are working on an old grammar where over the last decade or so the original files were lost in time and space. Maybe a one-off, semi automatic conversion is enough, but maybe a conversion script would be nice. If I end up writing an xml2ccg, I'll definitely submit a PR.

On Fri, Nov 16, 2018, 06:39 Dave H notifications@github.com wrote:

@dmhowcroft https://github.com/dmhowcroft Now I just need to find out how to use *.ccg files with OpenCCG and how to generate them from our grammar files, is there a tool already included in OpenCCG?

@shoeffner https://github.com/shoeffner, unfortunately I don't see any code for xml2ccg conversion in ccg2xml.py or elsewhere, though such a tool would definitely be helpful. If you need to put one together, I would start from looking at the parts of ccg2xml.py which assemble the XML for output and work from there backwards to reverse the process. If you end up doing this, please let us know and do submit a pull request so we can incorporate it into the larger project :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OpenCCG/openccg/issues/16#issuecomment-439288078, or mute the thread https://github.com/notifications/unsubscribe-auth/ABwHDwPabJygjd1HXlHNcY5E5366biWxks5uvk-ZgaJpZM4YcDMu .

shoeffner commented 6 years ago

ccg-editor.py seems to be an old relict: In fact, the build.xml chain copies the ccg_editor.py (note the _) which is just what is called when running the visccg script.

And while the ccg_editor.py was improperly indented, it does have a working call to ccg2xml.draw_parse. I created #18 which removes the outdated ccg-editor.py and mostly streamlines whitespaces in lex.py and ccg_editor.py, as well as the related build.xml files, but also fixes two minor issues:

This does not make the files perfect, but it allows viscgg to use the proper file, and load the arabic.ccg properly. The only thing which remains empty is the "Rules" tab, for the tiny.ccg grammar as well as the arabic.ccg.

mwhite14850 commented 6 years ago

Great, thanks! I’m traveling this week but will integrate it next week. -Mike

On Sun, Nov 18, 2018 at 11:45 AM Sebastian Höffner notifications@github.com wrote:

ccg-editor.py seems to be an old relict: In fact, the build.xml chain copies the ccgeditor.py (note the **) which is just what is called when running the visccg script.

And while the ccg_editor.py was improperly indented, it does have a working call to ccg2xml.draw_parse. I created #18 https://github.com/OpenCCG/openccg/pull/18 which removes the outdated ccg-editor.py and mostly streamlines whitespaces in lex.py and ccg_editor.py, as well as the related build.xml files, but also fixes two minor issues:

  • the type check mentioned above
  • changes an "arg == None" to "arg is None"

This does not make the files perfect, but it allows viscgg to use the proper file, and load the arabic.ccg properly. The only thing which remains empty is the "Rules" tab, for the tiny.ccg grammar as well as the arabic.ccg.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/OpenCCG/openccg/issues/16#issuecomment-439719970, or mute the thread https://github.com/notifications/unsubscribe-auth/ADxvzRTD5pVhtNWmuAx9cgWaGUgxJ_sDks5uwbjvgaJpZM4YcDMu .