query language extended and generalized

This commit is contained in:
aarne
2010-06-19 10:29:06 +00:00
parent 0493f640d3
commit a0f2ff0772
3 changed files with 146 additions and 59 deletions

View File

@@ -14,7 +14,6 @@ cat
Kind ; -- type of things, e.g. "person"
Property ; -- property of things, e.g. "employed at Google"
Individual ; -- one entity, e.g. "Google"
Activity ; -- action property, e.g. "work at Google"
Name ; -- person, company... e.g. "Eric Schmidt"
[Individual] {2} ; -- list of entities, e.g. "Larry Page, Sergey Brin"
@@ -24,17 +23,23 @@ fun
QSet : Set -> Query ; -- (give me | what are | which are | ) (S | the names of S | S's names)
QWhere : Set -> Query ; -- where are S
QWhat : Kind -> Property -> Query ; -- what K P
QWho : Property -> Query ; -- who P
QRel : Relation -> Set -> Query ; -- what R does S have
QInfo : Set -> Query ; -- (give me | ) (information about | all about) S
QCalled : Individual -> Query ; -- how is X (also | otherwise) (called | named | known) ;
QWhether : Answer -> Query ; -- is S P --- not in the corpus, but should be ??
AKind : Set -> Kind -> Answer ; -- S is a K
AInd : Set -> Individual -> Answer ; -- S is I
AName : Set -> Name -> Answer ; -- N is the name of S
AProp : Set -> Property -> Answer ; -- S is P
AAct : Set -> Activity -> Answer ; -- S As
SAll : Kind -> Set ; -- all Ks | the Ks
SRel : Set -> Relation -> Set ; -- S's Rs
SOne : Kind -> Set ; -- one K
SIndef : Kind -> Set ; -- a K
SDef : Kind -> Set ; -- the K
SPlural : Kind -> Set ; -- Ks
SOther : Kind -> Set ; -- other Ks
SInd : Individual -> Set ; -- X
@@ -45,13 +50,14 @@ fun
KRelKind : Kind -> Relation -> Set -> Kind ; -- K that is R of S
KRelPair : Kind -> Relation -> Kind ; -- S's with their R's
KProp : Property -> Kind -> Kind ; -- P K | K that is P
KAct : Activity -> Kind -> Kind ; -- K that Ps
KRel : Relation -> Kind ; -- R ---??
IName : Name -> Individual ;
ACalled : [Individual] -> Activity ;
PCalled : Individual -> Property ; -- also called I
PCalleds : [Individual] -> Property ; -- also called I or J
PIs : Individual -> Property ;
-- the test lexicon
@@ -62,11 +68,15 @@ fun
NCountry : Country -> Name ;
PCountry : Country -> Property ;
Located : Individual -> Property ;
Employed : Individual -> Property ;
Located : Set -> Property ;
Work : Individual -> Activity ;
HaveTitle : JobTitle -> Individual -> Activity ;
In : Set -> Property ;
HaveTitleAt : JobTitle -> Set -> Property ;
HaveTitle : JobTitle -> Property ;
Employed : Set -> Property ;
Named : Name -> Property ;
Start : Name -> Property ;
Organization : Kind ;
Place : Kind ;
@@ -83,8 +93,10 @@ fun
RName : Relation ;
RNickname : Relation ;
RJobTitle : Relation ;
CEO : JobTitle ;
ChiefInformationOfficer : JobTitle ;
Microsoft : Name ;
Google : Name ;
@@ -94,7 +106,9 @@ fun
EricSchmidt : Name ;
MarissaMayer : Name ;
UdiManber : Name ;
CarlGustavJung : Name ;
Jung : Name ;
BenFried : Name ;
}

View File

@@ -6,30 +6,32 @@ concrete QueryEng of Query = open
SyntaxEng,
ExtraEng,
(L = LangEng),
(M = MakeStructuralEng),
Prelude
in {
lincat
Move = Utt ; ---- Text ;
Query = Utt ;
Answer = Utt ;
Answer = Cl ; -- Utt ;
Set = NP ;
Relation = {cn : CN ; prep : Prep} ;
Kind = CN ;
Property = AP ; ---- {vp : VP ; typ : PropTyp} ;
Property = {ap : AP ; vp : VP} ;
Individual = NP ;
Activity = VP ;
Name = NP ;
[Individual] = [NP] ;
lin
MQuery q = q ; ---- mkText (mkPhr q) questMarkPunct ;
MAnswer a = a ; ---- mkText (mkPhr a) fullStopPunct ;
MAnswer a = mkUtt a ; ---- mkText (mkPhr a) fullStopPunct ;
QSet s =
let
ss : NP = s
| mkNP (mkNP theSg_Det L.name_N) (mkAdv possess_Prep s)
| mkNP (mkNP thePl_Det L.name_N) (mkAdv possess_Prep s)
| mkNP (GenNP s) sgNum L.name_N
| mkNP (GenNP s) plNum L.name_N ;
in
mkUtt (mkImp (mkVP give_V3 ss (mkNP i_Pron)))
@@ -37,24 +39,43 @@ lin
| mkUtt (mkQS (mkQCl (L.CompIP (L.IdetIP (mkIDet which_IQuant))) ss))
| mkUtt ss ;
QWhere s = mkUtt (mkQS (mkQCl where_IAdv s)) ;
QWhat k p =
mkUtt (mkQS (mkQCl (mkIP (what_IQuant | which_IQuant) (sgNum | plNum) k) p.vp)) ;
QWho p = mkUtt (mkQS (mkQCl whoSg_IP p.vp)) ;
QWhere s =
mkUtt (mkQS (mkQCl where_IAdv s))
| mkUtt (mkQS (mkQCl where_IAdv (mkCl s (mkA "located" | mkA "situated")))) ;
QRel r s =
mkUtt
(mkImp (mkVP give_V3 (mkNP and_Conj s (mkNP (mkQuant they_Pron) plNum r.cn)) (mkNP i_Pron)))
| mkUtt (mkQS (mkQCl (mkIP what_IQuant plNum r.cn) s have_V2))
| mkUtt (mkQS (mkQCl whatSg_IP
(mkClSlash (mkClSlash s have_V2) (mkAdv as_Prep (mkNP aPl_Det r.cn))))) ;
QInfo s =
let
info : NP = mkNP (all_NP | (mkNP information_N)) (mkAdv about_Prep s) ;
in
mkUtt (mkImp (mkVP give_V3 info (mkNP i_Pron)))
| mkUtt (mkQCl whatSg_IP
(mkClSlash (mkClSlash (mkNP youSg_Pron) (mkV2 know_V)) (mkAdv about_Prep s)))
| mkUtt info ;
QCalled i = mkUtt (mkQS (mkQCl how_IAdv (mkCl i (mkVP also_AdV (mkVP called_A))))) ;
QCalled i = mkUtt (mkQS (mkQCl how_IAdv (mkCl i
(mkVP (also_AdV | otherwise_AdV) (mkVP called_A))))) ;
AKind s k = mkUtt (mkCl s (mkNP aPl_Det k)) ; ---- a, fun of s
AProp s p = mkUtt (mkCl s p) ;
AAct s p = mkUtt (mkCl s p) ;
QWhether a = mkUtt (mkQS a) ;
AKind s k = (mkCl s (L.UseComp (L.CompCN k))) ;
AInd s i = (mkCl s i) ;
AName s n = (mkCl n (mkNP the_Det (mkCN L.name_N (mkAdv possess_Prep s)))) ;
AProp s p = (mkCl s p.vp) ;
SAll k = mkNP all_Predet (mkNP aPl_Det k) | mkNP thePl_Det k ;
SRel s r = mkNP (GenNP s) plNum r.cn ;
SRel s r = mkNP (GenNP s) plNum r.cn | mkNP (GenNP s) sgNum r.cn ;
SOne k = mkNP n1_Numeral k ;
SIndef k = mkNP a_Det k ;
SDef k = mkNP the_Det k ;
SPlural k = mkNP aPl_Det k ;
SOther k = mkNP aPl_Det (mkCN other_A k) ;
SInd i = i ;
@@ -63,23 +84,24 @@ lin
KRelSet r s =
mkCN r.cn (mkAdv r.prep s) ;
---- KRelsSet r q s =
---- mkCN r.cn (mkAdv r.prep s) ;
KRelsSet r q s =
mkCN (ConjCN and_Conj (BaseCN r.cn q.cn)) (mkAdv r.prep s) ;
KRelKind k r s =
mkCN k (mkRS (mkRCl that_RP (mkVP (mkNP aPl_Det (mkCN r.cn (mkAdv r.prep s)))))) ;
KRelPair k r = mkCN k (mkAdv with_Prep (mkNP (mkQuant they_Pron) plNum r.cn)) ;
KProp p k =
mkCN p k
| mkCN k (mkRS (mkRCl that_RP (mkVP p))) ;
KAct p k =
mkCN k (mkRS (mkRCl that_RP p)) ;
mkCN p.ap k
| mkCN k (mkRS (mkRCl that_RP p.vp)) ;
KRel r = r.cn ;
IName n = n ;
ACalled is = mkVP also_AdV (mkVP (mkAP (mkA2 called_A []) (mkNP or_Conj is))) ;
PCalled i = propCalled i ;
PCalleds is = propCalled (mkNP or_Conj is) ;
PIs i = propVP (mkVP i) ;
BaseIndividual = mkListNP ;
ConsIndividual = mkListNP ;
@@ -88,13 +110,17 @@ oper
-- structural words
about_Prep = mkPrep "about" ;
all_NP = mkNP (mkPN "all") ; ---
also_AdV = mkAdV "also" | mkAdV "otherwise" ;
also_AdV = mkAdV "also" ;
also_AdA = mkAdA "also" ;
as_Prep = mkPrep "as" ;
at_Prep = mkPrep "at" ;
called_A = mkA "called" | mkA "named" ;
give_V3 = mkV3 give_V ;
information_N = mkN "information" ;
other_A = mkA "other" ;
otherwise_AdV = mkAdV "otherwise" ;
otherwise_AdA = mkAdA "otherwise" ;
what_IQuant = M.mkIQuant "what" "what" ;
-- lexical constructors
mkName : Str -> NP =
@@ -102,6 +128,20 @@ oper
mkRelation : Str -> {cn : CN ; prep : Prep} =
\s -> {cn = mkCN (mkN s) ; prep = possess_Prep} ;
propAP : AP -> {ap : AP ; vp : VP} = \ap -> {
ap = ap ;
vp = mkVP ap
} ;
propVP : VP -> {ap : AP ; vp : VP} = \vp -> {
ap = PartVP vp ;
vp = vp
} ;
propCalled : NP -> {ap : AP ; vp : VP} = \i ->
propAP (mkAP (also_AdA | otherwise_AdA) (mkAP (mkA2 called_A []) i)) ;
-- lexicon
lincat
@@ -109,26 +149,52 @@ lincat
JobTitle = CN ;
lin
NCountry c = c.np ;
PCountry c = mkAP c.a ;
PCountry c = propAP (mkAP c.a) ;
Located i =
Located i = propAP (
mkAP (mkA2 (mkA "located") in_Prep) i
| mkAP (mkA2 (mkA "situated") in_Prep) i ;
| mkAP (mkA2 (mkA "situated") in_Prep) i
) ;
Employed i =
In i = propVP (mkVP (mkAdv in_Prep i)) ;
Employed i = propAP (
mkAP (mkA2 (mkA "employed") by8agent_Prep) i
| mkAP (mkA2 (mkA "paid") by8agent_Prep) i
| mkAP (mkA2 (mkA "active") at_Prep) i
| mkAP (mkA2 (mkA "professionally active") at_Prep) i ;
Work i =
| mkAP (mkA2 (mkA "professionally active") at_Prep) i
)
|
propVP (
mkVP (mkV2 (mkV "work") at_Prep) i
| mkVP (mkV2 (mkV "collaborate") in_Prep) i ;
| mkVP (mkV2 (mkV "collaborate") in_Prep) i
) ;
HaveTitle t i =
mkVP (mkVP (mkAP (mkA2 (mkA "employed") as_Prep) (mkNP t))) (mkAdv at_Prep i)
HaveTitle t =
propAP (
mkAP (mkA2 (mkA "employed") as_Prep) (mkNP t)
)
|
propVP (
mkVP (mkNP a_Det t)
| mkVP (mkV2 (mkV "work") as_Prep) (mkNP t)
-- | mkVP have_V2 (mkNP the_Det (mkCN (mkN2 (mkN "title")) (mkNP t)))
) ;
HaveTitleAt t i =
propAP (
mkAP (mkA2 (mkA "employed") as_Prep) (mkNP (mkNP t) (mkAdv at_Prep i))
)
|
propVP (
mkVP (mkVP (mkNP a_Det t)) (mkAdv at_Prep i)
| mkVP (mkVP (mkV2 (mkV "work") as_Prep) (mkNP t)) (mkAdv at_Prep i)
| mkVP (mkVP have_V2 (mkNP the_Det (mkCN (mkN2 (mkN "title")) (mkNP t)))) (mkAdv at_Prep i) ;
-- | mkVP (mkVP have_V2 (mkNP the_Det (mkCN (mkN2 (mkN "title")) (mkNP t))))
-- (mkAdv at_Prep i)
) ;
Named n = propAP (mkAP (mkA2 (mkA "named") []) n) ;
Start n = propVP (mkVP (mkV2 "start" with_Prep) n) ;
Organization = mkCN (mkN "organization") ;
Place = mkCN (mkN "place") ;
@@ -141,6 +207,9 @@ lin
Subregion = mkRelation "subregion" | mkRelation "sub-region" ;
RName = mkRelation "name" ;
RNickname = mkRelation "nickname" ;
RJobTitle = mkRelation "job title" | mkRelation "job" | mkRelation "position" |
mkRelation "appointment" | mkRelation "job position" | mkRelation "mandate" |
mkRelation "title" ;
USA = mkCountry "USA" "American" ;
Bulgaria = mkCountry "Bulgaria" "Bulgarian" ;
@@ -148,6 +217,7 @@ lin
OblastSofiya = mkName "Oblast Sofiya" ;
CEO = mkCN (mkN "CEO") ;
ChiefInformationOfficer = mkCN (mkN "Chief Information Officer") ;
Microsoft = mkName "Microsoft" ;
Google = mkName "Google" ;
@@ -157,6 +227,9 @@ lin
EricSchmidt = mkName "Eric Schmidt" ;
MarissaMayer = mkName "Marissa Mayer" ;
UdiManber = mkName "Udi Manber" ;
CarlGustavJung = mkName "Carl Gustav Jung" ;
Jung = mkName "Jung" ;
BenFried = mkName "Ben Fried" ;
oper
mkCountry : Str -> Str -> {np : NP ; a : A} =

View File

@@ -8,7 +8,7 @@ ps -tr "give me all subregions and their locations" | p
ps -tr "what are the subregions of all locations" | p
ps -tr "what subregions do all locations have" | p
ps -tr "what do all locations have as subregions" | p
ps -tr "what are the names of all locations that are subregion of Bulgaria" | p
ps -tr "what are the names of all locations that are subregions of Bulgaria" | p
ps -tr "give me the sub-regions of Bulgaria" | p
ps -tr "give me the Bulgarian sub-regions" | p
ps -tr "what are the Bulgarian sub-regions" | p
@@ -27,9 +27,9 @@ ps -tr "Oblast Sofiya is located in Bulgaria" | p
ps -tr "Oblast Sofiya is a subregion of Bulgaria" | p
ps -tr "Oblast Sofiya's location is Bulgaria" | p
ps -tr "Oblast Sofiya's location is in Bulgaria" | p
ps -tr "One subregion of Bulgaria is Oblast Sofiya" | p
ps -tr "A subregion of Bulgaria is Oblast Sofiya" | p
ps -tr "Oblast Sofyia is the name of a subregion of Bulgaria" | p
ps -tr "one subregion of Bulgaria is Oblast Sofiya" | p
ps -tr "a subregion of Bulgaria is Oblast Sofiya" | p
ps -tr "Oblast Sofiya is the name of a subregion of Bulgaria" | p
ps -tr "Bulgaria has a subregion - Oblast Sofiya" | p
ps -tr "Oblast Sofiya is a Bulgarian subregion" | p
ps -tr "Oblast Sofiya is a Bulgarian location" | p
@@ -45,7 +45,7 @@ ps -tr "all organizations' names" | p
ps -tr "organizations" | p
ps -tr "what is Microsoft" | p
ps -tr "what organization is Microsoft" | p
ps -tr "Give me information about Microsoft" | p
ps -tr "give me information about Microsoft" | p
ps -tr "all about Microsoft" | p
ps -tr "give me all organizations named Microsoft" | p
ps -tr "give me all organizations that start with Microsoft" | p
@@ -95,7 +95,7 @@ ps -tr "California is where Google is located" | p
ps -tr "california is the location of Google" | p
ps -tr "Google is situated in california" | p
ps -tr "California is where Google is situated" | p
ps -tr "Organizations located in a subregion of a location" | p
ps -tr "organizations located in a subregion of a location" | p
ps -tr "give me all organizations and in what subregion of what location they are located in" | p
ps -tr "which organizations are located in a place which is the subregion of which location" | p
ps -tr "where are the organizations located , in what subregion and region" | p
@@ -105,8 +105,8 @@ ps -tr "what are the organizations' locations by region and subregion" | p
ps -tr "all organizations and their locations with their subregions" | p
ps -tr "all organizations and the subregions of the locations they are located in" | p
ps -tr "give me all organizations and the regions they are located in , with their subregions" | p
ps -tr "the locations and subregions of all oragnizations" | p
ps -tr "Orgnaizations which a located in subregions of Bulgaria" | p
ps -tr "the locations and subregions of all organizations" | p
ps -tr "organizations which a located in subregions of Bulgaria" | p
ps -tr "which organizations are located in subregions of Bulgaria" | p
ps -tr "give me the organizations located in subregions of Bulgaria" | p
ps -tr "give me all organizations that are located in subregions of Bulgaria" | p
@@ -180,7 +180,7 @@ ps -tr "Google's location is California , which is in the USA" | p
ps -tr "Google is located in California , which is in the USA" | p
ps -tr "give me all people" | p
ps -tr "give me all about all people" | p
ps -tr "{simples} give me the names of all people" | p
ps -tr "give me the names of all people" | p
ps -tr "give me all people's names" | p
ps -tr "person" | p
ps -tr "all people" | p
@@ -299,30 +299,30 @@ ps -tr "what is the mandate of Udi Manber" | p
ps -tr "what is Udi Manber paid for" | p
ps -tr "what is Udi Manber's title" | p
ps -tr "what is Udi Manber working as" | p
ps -tr "what is Udi Manber apopinted as" | p
ps -tr "what is Udi Manber appointed as" | p
ps -tr "Ben Fried works as a Chief Information Officer" | p
ps -tr "Ben Fried's job position is Chief Information Officer" | p
ps -tr "Ben Fried is a Chief Information Officer" | p
ps -tr "Ben Fried's job title is Chief Information Officer" | p
ps -tr "Ben Fried's occupation is Chief Information Officer" | p
ps -tr "Ben Fried is Cheif Information Officer by occupation" | p
ps -tr "The Chief Information Officer is Ben Fried" | p
ps -tr "the Chief Information Officer is Ben Fried" | p
ps -tr "Ben Fried holds the position of Chief Information Officer" | p
ps -tr "Ben Fried is Chief Information Officer" | p
ps -tr "Ben Fried is appointed as Chief Information Officer" | p
ps -tr "Ben Fried is mandated as Chief Information Officer" | p
ps -tr "Ben Fried has the title of Chief Information Officer" | p
ps -tr "The title of Ben Fried is Chief Information Officer" | p
ps -tr "the title of Ben Fried is Chief Information Officer" | p
ps -tr "Ben Fried works in a position of Chief Information Officer" | p
ps -tr "The position of Ben Fried is Chief Information Officer" | p
ps -tr "the position of Ben Fried is Chief Information Officer" | p
ps -tr "Ben Fried's title is Chief Information Officer" | p
ps -tr "Ben fried's position is Chief Information Officer" | p
ps -tr "Ben Fried's position is Chief Information Officer" | p
ps -tr "where do all people work and what is their occupation" | p
ps -tr "who do all people work for and what's their occupation" | p
ps -tr "give me all people with their job titles and the Organization they work for" | p
ps -tr "give me all job titles with their holders and the Organization they work for" | p
ps -tr "give me all people with their job positions and the Organization they work for" | p
ps -tr "give me all job positions with their holders and the Organization they work for" | p
ps -tr "give me all people with their job titles and the organization they work for" | p
ps -tr "give me all job titles with their holders and the organization they work for" | p
ps -tr "give me all people with their job positions and the organization they work for" | p
ps -tr "give me all job positions with their holders and the organization they work for" | p
ps -tr "give me all people with their occupation and where they work" | p
ps -tr "give me all people with their occupations and where they work" | p
ps -tr "what are all people by occupation and who do they work for" | p
@@ -336,7 +336,7 @@ ps -tr "who operates where and in what position" | p
ps -tr "who is active at what organization in what capacity" | p
ps -tr "who is paid by which organization for what work" | p
ps -tr "who is appointed by which organization as in what capacity" | p
ps -tr "which orgniazation does employ whom as what" | p
ps -tr "which organization does employ whom as what" | p
ps -tr "which organization appoints whom in what position" | p
ps -tr "what is the job title of which person at what organization" | p
ps -tr "what is the occupation of all people and who do they work for" | p
@@ -409,7 +409,7 @@ ps -tr "Eric Schmidt is appointed at Google as what" | p
ps -tr "Eric Schidt works for Google in what position" | p
ps -tr "what is Eric Schmidt at Google" | p
ps -tr "what mandate has Eric Schmidt at Google" | p
ps -tr "The CEO of which organization is Eric Schmidt" | p
ps -tr "the CEO of which organization is Eric Schmidt" | p
ps -tr "Eric Schmidt is the CEO of which organization" | p
ps -tr "Eric Schmidt is employed as CEO of which organization" | p
ps -tr "where is Eric Schmidt the CEO" | p
@@ -526,7 +526,7 @@ ps -tr "Carl Gustav Jung's nicknames are Jung and Carl G Jung" | p
ps -tr "Jung and Carl G Jung are names of Carl Gustav Jung" | p
ps -tr "Jung and Carl G Jung are aliases of Carl Gustav Jung" | p
ps -tr "Larry Page and Sergey Brin are co-founders of Google" | p
ps -tr "Co-founders of Google are Larry Page and Sergey Brin" | p
ps -tr "co-founders of Google are Larry Page and Sergey Brin" | p
ps -tr "Larry Page is co-founder of Google and Sergey Brin is co-founder of Google" | p
ps -tr "Larry Page with Sergey Brin is co-founder of Google" | p
ps -tr "Larry Page and Sergey Brin co-founded Google" | p