APPLICATION GRAMMARS CHRISTINA UNGER (MERCURY.AI) EXAMPLE: NATURAL - - PowerPoint PPT Presentation

application grammars
SMART_READER_LITE
LIVE PREVIEW

APPLICATION GRAMMARS CHRISTINA UNGER (MERCURY.AI) EXAMPLE: NATURAL - - PowerPoint PPT Presentation

APPLICATION GRAMMARS CHRISTINA UNGER (MERCURY.AI) EXAMPLE: NATURAL LANGUAGE INTERFACES NLI applications are intermediaries between users and data. They need to speak the language of the user the language of the data Their job is to


slide-1
SLIDE 1

APPLICATION GRAMMARS

CHRISTINA UNGER (MERCURY.AI)

slide-2
SLIDE 2

EXAMPLE: NATURAL LANGUAGE INTERFACES

slide-3
SLIDE 3
slide-4
SLIDE 4
slide-5
SLIDE 5
slide-6
SLIDE 6
slide-7
SLIDE 7
slide-8
SLIDE 8
slide-9
SLIDE 9

NLI applications are intermediaries between users and data. They need to speak

  • the language of the user
  • the language of the data

Their job is to translate between both.

slide-10
SLIDE 10

NLI applications are intermediaries between users and data. They need to speak

  • the language of the user
  • the language of the data

Their job is to translate between both.

u s u a l l y e a s y ( s t r u c t u r e d a n d m a c h i n e

  • r

e a d a b l e )

slide-11
SLIDE 11

NLI applications are intermediaries between users and data. They need to speak

  • the language of the user
  • the language of the data

Their job is to translate between both.

m u c h h a r d e r ( n a t u r a l l a n g u a g e )

slide-12
SLIDE 12

NLI applications are intermediaries between users and data. They need to speak

  • the language of the user
  • the language of the data

Their job is to translate between both.

slide-13
SLIDE 13

Abstract syntax describing the domain Concrete syntax (English) Concrete syntax (Latvian) Concrete syntax (SQL/SPARQL/...) RGL (Eng) RGL (Lav)

slide-14
SLIDE 14

The Resource Grammar Library was developed to take care of "low-level" linguistic rules such as inflection, agreement, and word order. This enables the authors of application grammars to focus on the semantics when designing the abstract syntax.

https://www.grammaticalframework.org/lib/doc/translation.html

Application grammars are top-level grammars, the RGL is a library.

slide-15
SLIDE 15

THE RGL AS TOP-LEVEL GRAMMAR FOR MACHINE TRANSLATION: TOMORROW

slide-16
SLIDE 16

MAIN PROBLEM:

The RGL is low-level syntax-oriented.

  • It lacks a level of abstraction, e.g. to facilitate aligning natural language with data.
  • Semantic distinctions are assumed to be defined in application grammars. The RGL defines the

combinatorics of elements, but doesn't specify which elements can really go together.

  • RGL parsing creates spurious syntactic ambiguities.
slide-17
SLIDE 17

HANDS-ON: BUILDING AN APPLICATION GRAMMAR

slide-18
SLIDE 18

STEP 1: SCOPE

slide-19
SLIDE 19

STEP 1: SCOPE

I’m hungry!

slide-20
SLIDE 20

STEP 1: SCOPE

I want an Italian pizza!

slide-21
SLIDE 21

STEP 1: SCOPE

I have chili and papayas. What can I cook with this?

slide-22
SLIDE 22

STEP 1: SCOPE

Fast and healthy would be good.

slide-23
SLIDE 23

STEP 1: SCOPE

Do you have something vegetarian instead?

slide-24
SLIDE 24

STEP 1: SCOPE

No way, I hate garlic!

slide-25
SLIDE 25

STEP 1: SCOPE

Any fancy desserts for a date?

slide-26
SLIDE 26

STEP 1: SCOPE

Does this have peanuts? She’s allergic to peanuts...

slide-27
SLIDE 27

STEP 1: SCOPE

Grouping examples

Recipe Search

I’m hungry. Any burger recipes? Fast and healthy please. What can I do with papayas? I’m still hungry.

Recipe INFO

Does this contain peanuts? For how many people is this? What do I need? How many carbs does it have? Is this vegetarian?

User Preferences

I hate garlic. I’m vegetarian. I’m allergic to peanuts. I like cheese. I try to eat low-carb.

slide-28
SLIDE 28

Version 1

https://gist.github.com/cunger/1e5d9e404c6979fc45cdf366b52562e1 Writing application grammars is inherently domain-driven: All important choices depend on the scope and requirements of the application.

slide-29
SLIDE 29

Version 1

+ good level of abstraction

  • doesn’t generalize across domains
  • bservation: verbalization structures are usually the same across similar domains,

it’s mostly the lexical items that differ

slide-30
SLIDE 30

Version 2 (ontological heaven)

abstract Search = { cat Kind; Term Kind; Entity Kind; Attribute Kind; Relation Kind Kind; Search; SearchFilter; + functions for composition

slide-31
SLIDE 31

Version 2 (ontological heaven)

abstract SearchForRecipes = Search ** { fun Ingredient, Recipe : Kind; pizza, burger, dessert : Term Recipe; tomato, cheese, peanut : Term Ingredient; spaghetti_bolognese, pizza_hawaii : Entity Recipe; vegetarian, fast, easy, healthy : Attribute Recipe; with : Relation Ingredient Recipe; without : Relation Ingredient Recipe; }

slide-32
SLIDE 32

Version 2 (ontological heaven)

abstract SearchForCars = Search ** { fun Car, Equipment : Kind; porsche_cayenne : Entity Car; convertible, suv : Term Car; child_seat, air_conditioning : Term Equipment; fast, cheap : Attribute Car; with : Relation Equipment Car; without : Relation Equipment Car; }

slide-33
SLIDE 33

Version 2 (ontological heaven)

abstract SearchForMusic = Search ** { fun Song, Album, Artist : Kind; freddy_mercury : Entity Artist; made_in_heaven : Entity Album; bicycle_race : Entity Song; relaxed, fast, heavy : Attribute Song; song_by : Relation Song Artist; album_by : Relation Album Artist; contains : Relation Song Album; }

slide-34
SLIDE 34

svn checkout svn://molto-project.eu/wp4/YAQL

Yet Another Query Language (YAQL)

slide-35
SLIDE 35

Version 2 (ontological heaven)

+ generalizes across domains + thus easy to re-use grammar parts + tailored towards alignment with data

  • strong semantic orientation leads to a cat/lincat mismatch
slide-36
SLIDE 36

Version 2 (ontological heaven)

abstract Search = { cat Kind; Term Kind; Entity Kind; Attribute Kind; Relation Kind Kind; Search; SearchFilter;

slide-37
SLIDE 37

Version 2 (ontological heaven)

abstract Search = { cat Kind; Term Kind; -- CN Entity Kind; -- NP Attribute Kind; -- AP, Adv, RCl Relation Kind Kind; -- V2, N2, A2 Search; SearchFilter;

slide-38
SLIDE 38

Version 2 (ontological heaven)

abstract Search = { cat Kind; Term Kind; -- CN Entity Kind; -- NP Attribute Kind; -- { ap : AP, adv : Adv, rcl : RCl } Relation Kind Kind; -- { v2 : V2, n2 : N2, a2 : A2 } Search; SearchFilter;

slide-39
SLIDE 39

Version 2 (ontological heaven)

English

slide-40
SLIDE 40

Version 2 (ontological heaven)

English German

(or pick your favourite morphologically rich language)

slide-41
SLIDE 41

Version 2 (ontological heaven)

English German

(or pick your favourite morphologically rich language)

slide-42
SLIDE 42

Version 2 (ontological heaven)

abstract Search = { cat Kind; Term Kind; -- CN Entity Kind; -- NP Attribute Kind; -- { ap : AP, adv : Adv, rcl : RCl } Relation Kind Kind; -- { v2 : V2, n2 : N2, a2 : A2 } Search; SearchFilter;

slide-43
SLIDE 43

Version 2 (ontological heaven)

abstract Search = { cat Attribute_AP Kind; -- AP Attribute_Adv Kind; -- Adv Attribute_RCl Kind; -- RCl Relation_V2 Kind Kind; -- V2 Relation_N2 Kind Kind; -- N2 Relation_A2 Kind Kind; -- A2

slide-44
SLIDE 44

Version 2 (ontological heaven)

abstract Search = { cat Attribute_AP Kind; -- AP Attribute_Adv Kind; -- Adv Attribute_RCl Kind; -- RCl Relation_V2 Kind Kind; -- V2 Relation_N2 Kind Kind; -- N2 Relation_A2 Kind Kind; -- A2 + flat, no explosion

  • duplication of composition rules

(imagine you have several *_AP and *_CN categories and want to have AP-CN-modification)

slide-45
SLIDE 45

Version 3 (Syntax-Oriented)

abstract Search = { cat Noun; -- CN NounPhrase; -- NP AdjectivePhrase; -- AP VerbPhrase; -- VP Adverb; -- Adv Clause; -- Cl

slide-46
SLIDE 46

Version 3 (Syntax-Oriented)

abstract Search = { cat Noun; -- CN NounPhrase; -- NP AdjectivePhrase; -- AP VerbPhrase; -- VP Adverb; -- Adv Clause; -- Cl + perfect correspondence between cats and lincats

slide-47
SLIDE 47

Version 3 (Syntax-Oriented)

abstract Search = { cat Noun; -- CN NounPhrase; -- NP AdjectivePhrase; -- AP VerbPhrase; -- VP Adverb; -- Adv Clause; -- Cl + perfect correspondence between cats and lincats

  • plain duplication of the API
  • and where did the semantics go??

(syntax-orientation is not bad, but it's also not enough)

slide-48
SLIDE 48

Version 4

slide-49
SLIDE 49
slide-50
SLIDE 50

abstract RecipeSearch = { cat IngredientMassNoun; IngredientCountNoun; NounPhrase; NounPhrase_Neg; NounPhrase_NPI; NounPhrase_PPI; ...

slide-51
SLIDE 51

abstract RecipeSearch = { cat IngredientMassNoun; IngredientCountNoun; NounPhrase; NounPhrase_Neg; NounPhrase_NPI; NounPhrase_PPI; ... > flat > syntax-oriented > grammatic and semantic distinctions as needed

slide-52
SLIDE 52

abstract RecipeSearch = { cat IngredientMassNoun; IngredientCountNoun; NounPhrase; NounPhrase_Neg; NounPhrase_NPI; NounPhrase_PPI; ... > flat > syntax-oriented > grammatic and semantic distinctions as needed > modular

slide-53
SLIDE 53

Core.gf phrase and clause layer (re-usable across languages and domains) Domain.gf lexical items and constructrions Dialog.gf

Numbers.gf Dates.gf

slide-54
SLIDE 54

Core.gf phrase and clause layer (re-usable across languages and domains) Dialog.gf

Numbers.gf Dates.gf UserStory1.gf UserStory2.gf