How to trace Grammatical Framework parse: example WordNet imports badly

179 views Asked by At

I am trying to use WordNetEng concrete grammar https://github.com/GrammaticalFramework/gf-wordnet which, as I understand - uses all the standard grammar features (from the GF base installation), but greatly expands lexicon. My GF installation is working, e.g.:

> import C:\Workspace-Data\GF\AllEng.gfo
linking ... OK

Languages: AllEng
3031 msec
AllEngAbs> parse "turtle is good"
The parser failed at token 1: "turtle"
31 msecAllEngAbs> parse "dog is good"
PredVPS (MassNP (UseN dog_N)) (MkVPS (TTAnt TPres ASimul) PPos (UseComp (CompAP (PositA good_A))))
PredVPS (MassNP (UseN dog_N)) (MkVPS (TTAnt TPres ASimul) PPos (UseComp (CompNP (AdjAsNP (PositA good_A)))))
...

But I can import WordNetEng, but it does not recognize nor the turtle, nor other common words, including dog:

AllEngAbs> import C:\Workspace-Data\GF\WordNetEng.gf
linking ... OK

Languages: WordNetEng
5468 msec
WordNet> parse "tortoise is good"
The parser failed at token 1: "tortoise"
4234 msec
WordNet> parse "dog is good"
The parser failed at token 1: "dog"
0 msec

What is wrong? How GF can import the grammar (quite complex set of files) and then can not parse the simplest sentences? How can I debug this and correct this? Thanks!

Maybe there is option to list all the grammatical categories or terminals that have been imported in the session, e.g. in that way I could see whther the "tortoise" is imported or not?

I tried to generate random sentences, but there is strange error:

WordNet> gr
no trees found
0 msec
1

There are 1 answers

0
inariksit On BEST ANSWER

The WordNet lexicon is just a lexicon. It uses the categories from the standard RGL, but not the rest of the RGL functions. This is the abstract syntax:

abstract WordNet = Cat ** {

fun a_bomb_N : N ; 
...
fun zymotic_2_A : A ; 
}

So your result is completely expected.

Parse with RGL+WordNet

If you want to parse with the RGL and the WordNet lexicon, you can use the Parse module in the same repo, gf-wordnet/Parse.gf.

A warning though, that grammar can be very ambiguous. Most of the ambiguity comes from the fact that the every word has several versions, but you can also experiment with commenting out ParseExtend and see if that contributes to the multiple parses.

Use it like this:

$ gf ParseEng.gf
Parse> p "I am a human"
PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron iFem_Pron) (UseComp (CompCN (UseN human_N)))))) NoVoc
PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron iFem_Pron) (UseComp (CompNP (DetCN (DetQuant IndefArt NumSg) (UseN human_N))))))) NoVoc
PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (UseComp (CompCN (UseN human_N)))))) NoVoc
PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (UseComp (CompNP (DetCN (DetQuant IndefArt NumSg) (UseN human_N))))))) NoVoc

But it will still be ambiguous, because some of the words belong to lots of different synsets (20 synsets for the word good), and a long sentence may contain several such words.

Use WordNet lexicon in an application grammar

If you write an application grammar, you can always open WordNet in it, like any other module. For instance, to recreate the Foods example from the tutorial, we could write the parametrised module (functor) FoodsI.gf like this instead:

    incomplete concrete FoodsI of Foods = open Syntax, WordNet in {
    lincat
      Phrase = Cl ;
      Item = NP ;
      Kind = CN ;
      Quality = AP ;
    lin
      Is item quality = mkCl item quality ;
      This kind = mkNP this_Det kind ;
      That kind = mkNP that_Det kind ;
      These kind = mkNP these_Det kind ;
      Those kind = mkNP those_Det kind ;
      QKind quality kind = mkCN quality kind ;
      Very quality = mkAP very_AdA quality ;
  
      Wine = mkCN wine_1_N ; -- All these from WordNet
      Fish = mkCN fish_2_N ;
      ...
    }

and instantiate it for a concrete language like this

    concrete FoodsEng of Foods = FoodsI with
      (Syntax = SyntaxEng),
      (LexFoods = WordNetEng) ;