ArticleslgStudy

computer science

Grammatical Framework (programming language)

Grammatical Framework (programming language) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Grammatical Framework (programming language) rather than just read about it. In short: Grammatical Framework (GF) is a programming language for writing grammars of natural languages. GF is capable of parsing and generating texts in several languages simultaneously while working from a language-independent representation of meaning.

Grammatical Framework (programming language) — main illustration
Grammatical Framework (programming language) — illustration

Key takeaways

  • Grammatical Framework (programming language) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Grammatical Framework (programming language) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Grammatical Framework (programming language) from memory before moving on to harder problems.

Reference excerpt

Grammatical Framework (GF) is a programming language for writing grammars of natural languages. GF is capable of parsing and generating texts in several languages simultaneously while working from a language-independent representation of meaning. Grammars written in GF can be compiled into a platform independent format and then used from different programming languages including C and Java, C#, Python and Haskell. A companion to GF is the GF Resource Grammar Library, a reusable library for dealing with the morphology and syntax of a growing number of natural languages. Both GF itself and the GF Resource Grammar Library are open-source. Typologically, GF is a functional programming language. Mathematically, it is a type-theoretic formal system (a logical framework to be precise) based on Martin-Löf's intuitionistic type theory, with additional judgments tailored specifically to the domain of linguistics.

Language features a static type system, to detect potential programming errors functional programming for powerful abstractions support for writing libraries, to be used on other grammars tools for Information extraction, to convert linguistic resources into GF

Tutorial Goal: write a multilingual grammar for expressing statements about John and Mary loving each other.

Abstract and concrete modules In GF, grammars are divided to two module types:

an abstract module, containing judgement forms cat and fun. cat or category declarations list categories i.e. all the possible types of trees there can be. fun or function declarations state functions and their types, these must be implemented by concrete modules (see below). one or more concrete modules, containing judgement forms lincat and lin. lincat or linearization type definitions, says what type of objects linearization produces for each category listed in cat. lin or linearization rules implement functions declared in fun. They say how trees are linearized. Consider the following: Abstract syntax

Concrete syntax: English

Notice: Str (token list or "string") as the only linearization type.

Making a grammar multilingual A single abstract syntax may be applied to many concrete syntaxes, in our case one for each new natural language we wish to add. The same system of trees can be given:

different words different word orders different linearization types Concrete syntax: French

Translation and multilingual generation We can now use our grammar to translate phrases between French and English. The following commands can be executed in the GF interactive shell. Import many grammars with the same abstract syntax

Translation: pipe linearization to parsing

Multilingual generation: linearize into all languages

Parameters, tables Latin has cases: nominative for subject, accusative for object.

Ioannes Mariam amat "John-Nom loves Mary-Acc" Maria Ioannem amat "Mary-Nom loves John-Acc" We use a parameter type for case (just 2 of Latin's 6 cases). The linearization type of NP is a table type: from Case to Str. The linearization of John is an inflection table. When using an NP, we select (!) the appropriate case from the table. Concrete syntax: Latin

Discontinuous constituents, records In Dutch, the verb heeft lief is a discontinuous constituent. The linearization type of V2 is a record type with two fields. The linearization of Love is a record. The values of fields are picked by projection (.) Concrete syntax: Dutch

Variable and inherent features, agreement, Unicode support For Hebrew, NP has gender as its inherent feature – a field in the record. VP has gender as its variable feature – an argument of a table. In predication, the VP receives the gender of the NP. Concrete syntax: Hebrew

Visualizing parse trees GF has inbuilt functions which can be used for visualizing parse trees and word alignments. The following commands will generate parse trees for the given phrases and open the produced PNG image using the system's eog command.

Generating word alignment In languages L1 and L2: link every word with its smallest spanning subtree. Delete the intervening tree, combining links directly from L1 to L2. In general, this gives phrase alignment. Links can be crossing, phrases can be discontinuous. The align_words command follows a similar syntax:

Resource Grammar Library In natural language applications, libraries are a way to cope with thousands of details involved in syntax, lexicon, and inflection. The GF Resource Grammar Library is the standard library for Grammatical Framework. It covers the morphology and basic syntax for an increasing number of languages, currently including Afrikaans, Amharic (partial), Arabic (partial), Basque (partial), Bulgarian, Catalan, Chinese, Czech (partial), Danish, Dutch, English, Estonian, Finnish, French, German, Greek ancient (partial), Greek modern, Hebrew (fragments), Hindi, Hungarian (partial), Interlingua, Italian, Japanese, Korean (partial), Latin (partial), Latvian, Maltese, Mongolian, Nepali, Norwegian bokmål, Norwegian nynorsk, Persian, Polish, Punjabi, Romanian, Russian, Sindhi, Slovak (partial), Slovene (partial), Somali (partial), Spanish, Swahili (fragments), Swedish, Thai, Turkish (fragments), and Urdu. In addition, 14 languages have WordNet lexicon and large-scale parsing extensions. A full API documentation of the library can be found at the RGL Synopsis page. The RGL status document gives the languages currently available in the GF Resource Grammar Library, including their maturity.

Uses of GF GF was first created in 1998 at Xerox Research Centre Europe, Grenoble, in the project Multilingual Document Authoring. At Xerox, it was used for prototypes including a restaurant phrase book, a database query system, a formalization of an alarm system instructions with translations to 5 languages, and an authoring system for medical drug descriptions. Later projects using GF and involving third parties include:

… excerpt ends here. Continue reading the full article.

Illustrations

Grammatical Framework (programming language) illustration
Grammatical Framework (programming language): Word alignment for "Marie aime Jean" in French, Dutch and Latin
Word alignment for "Marie aime Jean" in French, Dutch and Latin
Grammatical Framework (programming language): Group photo from the 2009 GF Summer School in Gothenburg, Sweden
Group photo from the 2009 GF Summer School in Gothenburg, Sweden

Worked examples

Example 1 — a first encounter with Grammatical Framework (programming language)

Start with the simplest possible case. Write down what Grammatical Framework (programming language) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Grammatical Framework (programming language) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Grammatical Framework (programming language) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Grammatical Framework (programming language)

In research
Grammatical Framework (programming language) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Grammatical Framework (programming language) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Grammatical Framework (programming language) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computational linguistics, Functional languages, Grammar frameworks, so understanding it makes those chapters shorter.
In everyday life
Look for Grammatical Framework (programming language) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Grammatical Framework (programming language)” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Grammatical Framework (programming language) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Grammatical Framework (programming language) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Grammatical Framework (programming language) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Grammatical Framework (programming language) in simple terms?

Grammatical Framework (GF) is a programming language for writing grammars of natural languages. GF is capable of parsing and generating texts in several languages simultaneously while working from a language-independent representation of meaning.

Why does Grammatical Framework (programming language) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Grammatical Framework (programming language)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Grammatical Framework (programming language).

Tags

  • Computational linguistics
  • Functional languages
  • Grammar frameworks
  • Machine translation software
  • Natural language processing software
  • Translation software

Keep exploring