Language Games and Formal Grammars

Language Games and Formal Grammars
Aarne Ranta ([email protected])
Séminaire Sémantique, Université de Lille 3, 27 February 2013
Based on the articles
A. Ranta, R. Enache, and G. Détrez. Controlled Language for Everyday Use:
the MOLTO Phrasebook. In N. Fuchs and M. Rosner (eds), Controlled Natural
Language 2010, Springer LNCS/LNAI, vol. 7175, 2012. pp. 115-136.
A. Ranta, Type Theory and Universal Grammar. In Philosophia Scientiæ. Travaux
d’histoire et de philosophie des sciences, Issue CS 6, pp. 115-131, 2006.
R. Cooper and A. Ranta, Natural Languages as Collections of Resources. In R.
Cooper and R. Kempson (eds), Language in Flux: Dialogue Coordination, Language
Variation, Change, pp. 109-120, College Publications, London, 2008.
Funded by the MOLTO project (FP7-ICT-247914 www.molto-project.eu)
Some keywords
formal grammars, formal semantics, language games, Sapir-Whorf,
universal grammar, context, dialogue, ambiguity, disambiguation, translation
Formal grammars
Chomsky, Syntactic Structures, 1957
Languages defined by formally precise rules
S -> NP VP
Formal semantics
Montague, Formal Philosophy, 1974
Formally precise rules on formally specified languages
s(np,vp)* = np*(vp*)
All grammars leak
Sapir, Language, 1925
Modern language technology: statistical models (e.g. Google translate)
Language games
”The language is not a formal system, but a family of language
games”
Wittgenstein, Philosophical Investigations, 1953
Stenius, ”Mood and Language Game”, 1967
Rule systems that relate utterances to other actions
if the Master says "brick", bring him a brick
Sapir-Whorf
Different languages means different realities
• time for Hopi Indians 6= time for Englishmen 6= time for Frenchmen
A recent result: Hebrew kids learn gender differences earlier than
Finnish kids, English kids are somewhere in between
Some claims
We can have formal grammars and formal semantics of language
games
We can translate language games
Different games need different kinds of semantics
Finnish kids do learn genders, just a bit later
How to define a language game
Abstract syntax: the pure structure of the moves of game
fun Like : Person -> Person -> Fact
Concrete syntax: how the moves are realized (linearized) in different languages
lin
lin
lin
lin
Like
Like
Like
Like
x
x
x
x
y
y
y
y
=
=
=
=
x
x
x
y
++
++
++
++
"likes"
"tycker
"pitää"
"piace"
++ y
om" ++ y
++ y ++ ":stä"
++ "a" ++ y
-----
Eng
Swe
Fin
Ita
Grammatical Framework
GF = Logical Framework + concrete syntax
Logical Framework = higher-level type theory
The framework idea: no uniform logic - but a framework for defining
special logics
Translation:
1. parse in source language to type theory
2. linearize type theory to target language
A. Ranta, Grammatical Framework. Programming with Multilingual
Grammars, CSLI, 2011.
http://www.grammaticalframework.org
Some complications
French, Italian: agreement, rection, clitics (questo piace a Maria vs.
questo mi piace ; questi mi piacciono)
lin Like x y = y.s ! nominative ++ case x.isPron of {
True => x.s ! dative ++ piacere_V ! y.agr ;
False => piacere_V ! y.agr ++ "a" ++ x.s ! accusative
}
oper piacere_V = verbForms "piacere" "piace" "piacciono" ...
Moreover: contractions (piace ai bambini), tenses, mood, ...
The GF Resource Grammar Library
Hide the low-level linguistic details by a grammar library API:
lin
lin
lin
lin
Like
Like
Like
Like
x
x
x
x
y
y
y
y
=
=
=
=
mkCl
mkCl
mkCl
mkCl
x
x
x
y
(mkV2
(mkV2
(mkV2
(mkV2
(mkV "like")) y
-(mkV "tycker") "om") y
-(mkV "pitää") elative) y -piacere_V dative) x
--
A general resource for all language games.
Currently available for 26 languages.
Eng
Swe
Fin
Ita
Semantics?
Baseline: just expressed by abstract syntax trees.
Trip X Y
•
•
•
•
from X to Y
a ticket from X to Y
I would like to go from X to Y
can you give me a ticket from X to Y
All equal as dialogue moves, just diffing in syntactic sugar
Semantics in the framework
semantics = abstract syntax
concrete syntax is compositional
(t(x1, . . . , xn))∗ = t∗(x∗1, . . . , x∗n)
The MOLTO project
Multilingual On-Line Translation
High-quality domain-specific translation with GF for 15 languages
MOLTO domains:
•
•
•
•
mathematics
patents
museum object descriptions
a tourist phrasebook
The MOLTO Phrasebook
http://www.grammaticalframework.org/demos/phrasebook/
Touristic phrases in 19 languages
Idiomacy, context dependence, disambiguation
Web application, mobile Android application
The semantics and translation of idioms
Questions:
• What is the meaning of the German phrase bitte ?
• What is bitte in English?
Bitte
Customer:
Waiter:
Customer:
Waiter:
Ein Bier bitte.
Bitte.
Danke.
Bitte.
Bitte in English and Swedish
English
A beer please.
Here we are.
Thank you.
You’re welcome.
Swedish
En öl tack.
Var så god.
Tack.
Var så god.
German
Ein Bier bitte.
Bitte.
Danke.
Bitte.
A semantic model
cat
Phrase ; Item
fun
GivePlease
HereWeAre
ThankYou
YouAreWelcome
ABeer
:
:
:
:
:
Item -> Phrase
Phrase
Phrase
Phrase
Item
English concrete syntax
lin
GivePlease item
HereWeAre
ThankYou
YouAreWelcome
ABeer
=
=
=
=
=
item ++ "please"
"here we are"
"thank you"
"you are welcome"
"ein Bier"
German concrete syntax
lin
GivePlease item
HereWeAre
ThankYou
YouAreWelcome
ABeer
=
=
=
=
=
item ++ "bitte"
"bitte"
"Danke"
"bitte"
"ein Bier"
Disambiguation
Natural language is ambiguous
Different languages are ambiguous in different ways
Disambiguation
Natural language is ambiguous
Different languages are ambiguous in different ways
But: ambiguity is resolved in context
Disambiguation
Despite the ”hopeless ambiguity” of natural language,
ambiguity can usually be resolved by asking a simple question and
getting a simple answer - in the same language!
Politeness and gender
Another case for disambiguation:
Are you Swedish?
What is this in French/German/etc?
French:
YouFamMale:
YouFamFemale:
YouPolMale:
YouPolFemale:
Est-ce
Est-ce
Est-ce
Est-ce
que
que
que
que
tu es suédois ?
tu es suédoise ?
vous êtes suédois ?
vous êtes suédoise ?
German:
YouFamMale, YouFamFemale:
YouPolMale, YouPolFemale:
Bist du schwedisch?
Sind Sie schwedisch?
Disambiguation grammar
concrete DisambPhrasebookEng of Phrasebook = PhrasebookEng [YouFamMale, YouFamFemale, YouPolMale, YouPolFemale]
** open SyntaxEng, ParadigmsEng in {
lin
YouFamMale
= mkNP you_NP (mkAdv "(familiar,male)") ;
YouFamFemale = mkNP you_NP (mkAdv "(familiar,female)") ;
YouPolMale
= mkNP you_NP (mkAdv "(polite,male)") ;
YouPolFemale = mkNP you_NP (mkAdv "(polite,female)") ;
}
Displaying the disambiguation to the user
English input:
• Are you Swedish?
French output:
•
•
•
•
Est-ce que tu es suédois ? (Are you (Familiar,Male) Swedish?)
Est-ce que tu es suédoise ? (Are you (Familiar,Female) Swedish?)
Est-ce que vous êtes suédois ? (Are you (Polite,Male) Swedish?)
Est-ce que vous êtes suédoise ? (Are you (Polite,Female) Swedish?)
German output:
• Bist du Schwedisch? (Are you (Familiar,Male) Swedish? / Are
you (Familiar,Female) Swedish?)
• Sind Sie Schwedish? (Are you (Polite,Male) Swedish? / Are you
(Polite,Female) Swedish?)
Scaling up the language game
Some more things in the MOLTO Phrasebook
category
Phrase
Greeting
Sentence
Question
Proposition
Object
Item
Kind
Quality
Place
PlaceKind
Person
Action
Nationality
Language
Citizenship
Country
Currency
Number
Price
explanation
complete phrase, unit of translation
idiomatic greeting
declarative sentence
question, either yes/no or wh
can be used as sentence or question
object of wanting, ordering, etc
a single entity
a type of an item
qualification of an item
location
type of location
agent wanting or doing something
proposition about a Person
complex of language, property, country
language (can be without nationality)
property (can be without language)
country (can be without language)
currency
number expression in words
price (number + currency)
example
Where are you?
hello
I am in the bar
where are you
this pizza is good
two pizzas and a beer
this pizza
pizza
very good
the bar
bar
you
you are here
Swedish, Sweden
Flemish
Belgian
Belgium
Swedish crown
two hundred and five
sixty-five dollars
arguments
Number, Kind
Quality, Kind
Kind
PlaceKind
Proposition
Proposition
Action
Person, Object
Person, Citizenship
Person, Place
Person, Sentence
Person, Person
Person, Question
Person, Number
Person, Number
Person, Name
Person
Person, Item
Person, Country
Person, Language
Person, Currency
Person, Object
Person, Place
value
Object
Kind
Item
Place
Sentence
Question
Proposition
Action
Action
Action
Action
Action
Action
Action
Action
Action
Action
Action
Action
Action
Action
Action
Action
examples
five pizzas
Italian pizza
this pizza, the pizzas
the bar, a bar
the bar is open, the bar isn’t open
is the bar open
I speak Polish
you have beer, you have no beer
you are German
you are in the bar
you know that I am in the bar
you know my wife
you know how far the bar is
I am seventy years old
I have six children
my name is Bond
I am hungry
I like this pizza
I live in Sweden
I speak Polish
I have Swedish crowns
I want two apples
I want to go to the hospital
Person
Item
Item, Price
Place
Place, Date
Place, Day
Place, Date
Person
Number, Currency
Place
Place, Place
Transport, Place
Question
Question
Proposition
Proposition
Proposition
Proposition
Greeting
Person
Proposition
Question
Question
Question
how old are you
how much does the pizza cost
the pizza costs five euros
the museum is open
the museum is open today
the museum is open on Mondays
see you in the bar on Monday
my wife, your husband
five euros
how far is the zoo
how far is the centre from the hotel
which bus goes to the hotel
How far can we get?
Improving precision by recognizing the ”language game”
s’il vous plaı̂t
• if he pleases you, direct syntactic translation
• please, language game translation
he is fifty
• il est cinquante, direct syntactic translation
• il a cinquante ans, language game translation
Ultimate back-up: statistical translation
Conclusion
Language games are good for language technology!
•
•
•
•
•
They
They
They
They
They
reduce ambiguity.
can be shared between languages.
connect language with action.
permit formal grammars.
permit simple, abstract semantics.
Question: how much of language can we cover by formalizing more
and more language games?