Here are some handy tips for making it easier to develop grammars with VisCCG.
When you create the XML files from your .ccg specification, it adds the name of your grammar by default to the files. For example, if you have a file called tagalog.ccg, the following is the default behavior:
~/devel/grammars/tagalog jbaldrid$ ls tagalog.ccg ~/devel/grammars/tagalog jbaldrid$ ccg2xml tagalog.ccg ccg2xml: Processing tagalog.ccg Outputting XML file: ./tagalog-lexicon.xml Outputting XML file: ./tagalog-grammar.xml Outputting XML file: ./tagalog-morph.xml Outputting XML file: ./tagalog-rules.xml Outputting XML file: ./tagalog-testbed.xml Outputting XML file: ./tagalog-types.xml ~/devel/grammars/tagalog jbaldrid$ ls tagalog-grammar.xml tagalog-rules.xml tagalog.ccg tagalog-lexicon.xml tagalog-testbed.xml tagalog-morph.xml tagalog-types.xml
You can change the prefix by using the -p option to ccg2xml. For example, say you want to save various versions of your grammar as you are working on it. You might do this:
~/devel/grammars/tagalog jbaldrid$ ccg2xml -p "tagalog-v2-" tagalog.ccg ccg2xml: Processing tagalog.ccg Outputting XML file: ./tagalog-v2-lexicon.xml Outputting XML file: ./tagalog-v2-grammar.xml Outputting XML file: ./tagalog-v2-morph.xml Outputting XML file: ./tagalog-v2-rules.xml Outputting XML file: ./tagalog-v2-testbed.xml Outputting XML file: ./tagalog-v2-types.xml
This will be handy for creating HTML visualization with the ccg-grammardoc command, discussed below.
There is a handy utility for visualizing your OpenCCG grammars in HTML called ccg-grammardoc (created by Scott Martin at Ohio State University). It assumes that the files you want to display have no prefixes, so they should be named grammar.xml rather than tagalog-grammar.xml, for example. We can use the -p option to produce such files, as such:
~/devel/grammars/tagalog jbaldrid$ ccg2xml -p "" tagalog.ccg ccg2xml: Processing tagalog.ccg Outputting XML file: ./lexicon.xml Outputting XML file: ./grammar.xml Outputting XML file: ./morph.xml Outputting XML file: ./rules.xml Outputting XML file: ./testbed.xml Outputting XML file: ./types.xml
Now you are ready to run ccg-grammardoc:
~/devel/grammars/tagalog jbaldrid$ ccg-grammardoc -d tagalog_page [grammardoc] Creating directory /Users/jbaldrid/devel/grammars/tagalog/tagalog_page [grammardoc] Using GrammarDoc HTML Documenter [grammardoc] Documenting /Users/jbaldrid/devel/grammars/tagalog [grammardoc] Generating documentation to /Users/jbaldrid/devel/grammars/tagalog/tagalog_page [grammardoc] Parsing grammar.xml [grammardoc] Parsing lexicon.xml [grammardoc] Parsing morph.xml [grammardoc] Parsing rules.xml [grammardoc] Parsing types.xml [grammardoc] Writing /Users/jbaldrid/devel/grammars/tagalog/tagalog_page/grammardoc.css [grammardoc] Writing /Users/jbaldrid/devel/grammars/tagalog/tagalog_page/lexicon.js [grammardoc] Generating index.html [grammardoc] Generating lexicon.html [grammardoc] Generating morph.html [grammardoc] Generating rules.html [grammardoc] Generating types.html [grammardoc] Done
This creates a webpage in the directory tagalog_page with the HTML produced from your grammar:
~/devel/grammars/tagalog jbaldrid$ ls tagalog_page/ grammardoc.css lexicon.html morph.html types.html index.html lexicon.js rules.html
Look at index.html using a web browser to see what was produced.