Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
997 views
in Technique[技术] by (71.8m points)

How to get the plural of a noun in GF

In some situations when a user wants only the plural of a noun such as:

mkN("apple");

What is the best practice to get the machine to print out the result apples instead of printing the whole set apple apple's apples apples'.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Relevant flags to cc in GF shell

To get cc (short for compute_concrete) in the GF shell to print only one result, you can use the flag -one. Like this:

$ gf
> i -retain alltenses/ParadigmsEng.gfo
> cc mkN "apple"
{s = table
       ParamX.Number
       [table ResEng.Case ["apple"; "apple's"];
        table ResEng.Case ["apples"; "apples'"]];
 g = ResEng.Neutr; lock_N = <>}

> cc -one mkN "apple"
apple

If you apply the flag for the N, then the first thing it prints out is the singular form. So how to fix the number to get plural instead?

Fixed number

N is a category of nouns, and nouns have inflection tables. N can be used to create many different things: the nominative forms apple and apples can become heads of noun phrases, singular or plural. The genitive forms can become determiners ("the apple's sweet taste" or "all my apples' cores are rotten"). So N is open for number and case. When you print out the forms of a N without any extra flags, it makes sense to show them all.

If you want to go a step further, and only restrict apples to be plural, you need to make it into a plural NP:

apples_NP = mkNP aPl_Det (mkN "apple") ;

Open for case

Note that a NP is still open for case. In fact, the inflection table of NP is as big as N's, even though we know the number. That's because NPs can be made out of pronouns, and pronouns can inflect more than nouns. This is the worst case for a NP:

> cc -table i_NP
s . ResEng.NCase ResEng.Nom => I
s . ResEng.NCase ResEng.Gen => my
s . ResEng.NPAcc => me
s . ResEng.NPNomPoss => mine

Of course, for a NP made out of a noun, most of those fields are identical.

> cc -table apples_NP
s . ResEng.NCase ResEng.Nom => apples
s . ResEng.NCase ResEng.Gen => apples'
s . ResEng.NPAcc => apples
s . ResEng.NPNomPoss => apples

But because some NPs are different in all 4 fields, that's why the GF lincat for NP needs to have them.

Display apples in the GF shell

To get GF shell only display apples, you need to create a NP out of the noun, and then call cc -one on the plural NP. Here's a GF file you can paste into a file called Apples.gf.

resource Apples = open ParadigmsEng, SyntaxEng in {

  oper

    apple_N : N = mkN "apple" ;

    apples_NP : NP = mkNP aPl_Det apple_N ;
}

Go to GF shell:

> i -retain Apples.gf
> cc -one apples_NP
apples

Output apples in any other situation

If you use apples_NP as a subject or object in any sentence, you will get the string apples. If you give it as an argument to Extend.GenNP, you get a quantifier with the string apples'.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...