Lists in GF

45 views
Skip to first unread message

Nardi Lam

unread,
Apr 29, 2018, 2:40:21 AM4/29/18
to Grammatical Framework
Hi all,

I’ve seen code in GF using lists, like [NP]. Is there any documentation around for them? I’ve noticed they make you declare implementation functions like BaseNP and ConsNP but I’m not sure of the possibilities/limits. For example, is it possible to have an empty list?

Best,
Nardi

Inari Listenmaa

unread,
Apr 30, 2018, 7:42:40 AM4/30/18
to Grammatical Framework
Hi,

the following is from the GF book:

C.4.3 List categories
Since categories of lists of elements of another category are a common idiom, the following syntactic sugar is available:
cat [C] {n}
abbreviates a set of three judgements:
cat ListC ;
fun BaseC : C -> … -> C -> ListC ; --n C’s
fun ConsC : C -> ListC -> ListC


The functions BaseC and ConsC are automatically generated in the abstract syntax, but their linearizations, as well as the linearization type of ListC,
must be defined manually. The type expression [C] is in all contexts interchangeable with ListC.

If you haven’t seen it yet, have a look at the abstract syntax for conjunctions in the RGL: https://github.com/GrammaticalFramework/GF/blob/master/lib/src/abstract/Conjunction.gf The lists in the RGL are for 2 arguments, “X and Y”, so empty lists are not possible. (I suppose [NP]{0} might work in theory? :-P)

The purpose of lists in GF is mostly to generalise coordination, e.g. “I saw John, Mary, Alice, Bob and Charlie”, so you don’t need a different syntactic function for 2, 3, 4, 5 etc. objects, but just one for an NP object, which you can build out of a ListNP.  The RGL has functions ConjC : Conj -> ListC -> C for all categories that have a ListC. For instance, here you can see the tree for “John and I walk”:

PredVP (ConjNP and_Conj (BaseNP (UsePN john_PN) (UsePron i_Pron))) (UseV walk_V)

ListC is usually implemented as exactly like the lincat of C, but with two s fields (s1, s2), you can see examples here: https://github.com/GrammaticalFramework/GF/blob/master/lib/src/english/ConjunctionEng.gf#L52-L61 You might find lists more restricted than you’re used to; there’s not really much else to do than concatenate the lists using a conjunction. For instance, you cannot peek into a list and decide “if the 3th element has parameter Foo, then do something”.

Hope this helps; if you have more questions, just ask!

Cheers,
Inari

-- 

--- 
You received this message because you are subscribed to the Google Groups "Grammatical Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gf-dev+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aarne Ranta

unread,
May 4, 2018, 2:52:57 AM5/4/18
to gf-...@googlegroups.com
Inari, thanks for the answer!

Nardi, thanks for the question!

I thought that this issue surely is covered in the GF reference manual on the web. But it turned out that it isn't. We will have to add it, so thanks both for the reminder!

  Aarne.


To unsubscribe from this group and stop receiving emails from it, send an email to gf-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to the Google Groups "Grammatical Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gf-dev+unsubscribe@googlegroups.com.

ma...@nardilam.nl

unread,
Feb 1, 2021, 2:10:50 PMFeb 1
to Grammatical Framework
Bit of a resurrection, but I started using GF this week again for the first time in a long while, and I noticed there still isn't any documentation on this feature ;)
There is only a small mention that "[C a b]" is a list category in the reference manual, but no explanation.

Op vrijdag 4 mei 2018 om 08:52:57 UTC+2 schreef Aarne Ranta:
To unsubscribe from this group and stop receiving emails from it, send an email to gf-dev+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to the Google Groups "Grammatical Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gf-dev+un...@googlegroups.com.

Inari Listenmaa

unread,
Feb 2, 2021, 12:39:33 AMFeb 2
to Grammatical Framework
Thanks for the report! I'm planning to improve the reference manual/other documentation (as per https://github.com/GrammaticalFramework/gf-core/issues/94), I'll put lists on the list.

Inari

Inari Listenmaa

unread,
Feb 22, 2021, 10:26:33 AMFeb 22
to Grammatical Framework
Here's a section on lists in the reference manual https://github.com/GrammaticalFramework/gf-core/pull/99

And a ~4000-word blog post on lists, all you wanted to know and much more 😅 https://inariksit.github.io/gf/2021/02/22/lists.html 

Inari
Reply all
Reply to author
Forward
0 new messages