Search code examples
gf

How to encode a noun with modifiers like "offset direction" in GF?


I doing my first steps with an GF application grammar.

I wonder how I can encode a noun with noun modifiers like "offset direction" or "income tax" in GF.

This link explains the constructions I am interested in: noun-modifiers

I tried using mkCN : N -> NP -> CN:

mkCN (mkN "offset") (mkNP (mkN "direction"))

which basically works, but the plural is constructed as offsets direction rather than offset directions.

I can't find other obvious constructors under CN or NP.


Solution

  • Alternative 1: put them into lexicon (N) directly

    The simplest solution is to make them all into nouns from the beginning, as follows:

    lin offset_direction_N = mkN "offset direction" ;
    

    For English, the smart paradigms work just fine with extra fluff before the head word, because the pattern matching is really just about the end, so we get fly~flies, boy~boys etc. (This is generally not true of other languages' morphological paradigms, but if you look at their Paradigms modules, they usually have a special way of dealing with compound words. If English is the only language in your application, feel free to ignore all of this.)

    Alternative 2: create compounds at runtime

    Is there a need to build these constructions on the fly from an existing lexicon that only has single entries? If so, then the RGL API doesn't have a function specifically for that.

    However, there is a module called Extend, which has a function CompoundN : N -> N -> N.

    So how to use Extend? You have been using the RGL API, where all of the mkX opers are available when you open the Syntax and Paradigms modules. The Extend module is newer than the core RGL, so its functions are not shown in the synopsis. But you can use them just like you'd use the Syntax and Paradigms modules. Here's an example usage:

    resource Test = open ParadigmsEng, ExtendEng in {
    
      oper
        offset_N : N = mkN "offset" ;
        direction_N : N = mkN "direction" ;
    
        offset_direction_N : N = CompoundN offset_N direction_N ;
    }
    

    For more information on the Extend module, see https://inariksit.github.io/gf/2021/02/15/rgl-api-core-extensions.html#extend.