forked from GitHub/gf-core
query language generalized and extended ; added README
This commit is contained in:
@@ -10,8 +10,10 @@ cat
|
|||||||
Query ;
|
Query ;
|
||||||
Answer ;
|
Answer ;
|
||||||
Set ; -- the set requested, e.g. "all persons"
|
Set ; -- the set requested, e.g. "all persons"
|
||||||
Relation ; -- something of something, e.g. "subregion of Bulgaria"
|
Interrogative ; -- interrog. pron. e.g. "who"
|
||||||
|
Function ; -- something of something, e.g. "subregion of Bulgaria"
|
||||||
Kind ; -- type of things, e.g. "person"
|
Kind ; -- type of things, e.g. "person"
|
||||||
|
Relation ; -- relation between things,e.g. "employed at"
|
||||||
Property ; -- property of things, e.g. "employed at Google"
|
Property ; -- property of things, e.g. "employed at Google"
|
||||||
Individual ; -- one entity, e.g. "Google"
|
Individual ; -- one entity, e.g. "Google"
|
||||||
Name ; -- person, company... e.g. "Eric Schmidt"
|
Name ; -- person, company... e.g. "Eric Schmidt"
|
||||||
@@ -22,13 +24,16 @@ fun
|
|||||||
MAnswer : Answer -> Move ;
|
MAnswer : Answer -> Move ;
|
||||||
|
|
||||||
QSet : Set -> Query ; -- (give me | what are | which are | ) (S | the names of S | S's names)
|
QSet : Set -> Query ; -- (give me | what are | which are | ) (S | the names of S | S's names)
|
||||||
QWhere : Set -> Query ; -- where are S
|
QWhere : Set -> Query ; -- where are S
|
||||||
QWhat : Kind -> Property -> Query ; -- what K P
|
QWhat : Interrogative -> Property -> Query ; -- who P
|
||||||
QWho : Property -> Query ; -- who P
|
QWhatWhat : Interrogative -> Interrogative -> Relation -> Query ; -- who R what
|
||||||
QRel : Relation -> Set -> Query ; -- what R does S have
|
QWhatWhere : Interrogative -> Relation -> Query ; -- who R where --- overgenerating
|
||||||
QInfo : Set -> Query ; -- (give me | ) (information about | all about) S
|
QRelWhere : Set -> Relation -> Query ; -- where does S R --- overgenerating
|
||||||
QCalled : Individual -> Query ; -- how is X (also | otherwise) (called | named | known) ;
|
QFun : Function -> Set -> Query ; -- what R does S have
|
||||||
QWhether : Answer -> Query ; -- is S P --- not in the corpus, but should be ??
|
QFunPair : Set -> Function -> Query ; -- S and their R's
|
||||||
|
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
|
AKind : Set -> Kind -> Answer ; -- S is a K
|
||||||
AInd : Set -> Individual -> Answer ; -- S is I
|
AInd : Set -> Individual -> Answer ; -- S is I
|
||||||
@@ -36,7 +41,7 @@ fun
|
|||||||
AProp : Set -> Property -> Answer ; -- S is P
|
AProp : Set -> Property -> Answer ; -- S is P
|
||||||
|
|
||||||
SAll : Kind -> Set ; -- all Ks | the Ks
|
SAll : Kind -> Set ; -- all Ks | the Ks
|
||||||
SRel : Set -> Relation -> Set ; -- S's Rs
|
SFun : Set -> Function -> Set ; -- S's Rs
|
||||||
SOne : Kind -> Set ; -- one K
|
SOne : Kind -> Set ; -- one K
|
||||||
SIndef : Kind -> Set ; -- a K
|
SIndef : Kind -> Set ; -- a K
|
||||||
SDef : Kind -> Set ; -- the K
|
SDef : Kind -> Set ; -- the K
|
||||||
@@ -45,12 +50,16 @@ fun
|
|||||||
SInd : Individual -> Set ; -- X
|
SInd : Individual -> Set ; -- X
|
||||||
SInds : [Individual] -> Set ; -- X and Y
|
SInds : [Individual] -> Set ; -- X and Y
|
||||||
|
|
||||||
KRelSet : Relation -> Set -> Kind ; -- R of S | S's R
|
IWho : Interrogative ; -- who
|
||||||
KRelsSet : Relation -> Relation -> Set -> Kind ; -- R and Q of S
|
IWhat : Interrogative ; -- what
|
||||||
KRelKind : Kind -> Relation -> Set -> Kind ; -- K that is R of S
|
IWhich : Kind -> Interrogative ; -- which K | what K | which Ks | what Ks
|
||||||
KRelPair : Kind -> Relation -> Kind ; -- S's with their R's
|
|
||||||
|
KFunSet : Function -> Set -> Kind ; -- R of S | S's R
|
||||||
|
KFunsSet : Function -> Function -> Set -> Kind ; -- R and Q of S
|
||||||
|
KFunKind : Kind -> Function -> Set -> Kind ; -- K that is R of S
|
||||||
|
KFunPair : Kind -> Function -> Kind ; -- S's with their R's
|
||||||
KProp : Property -> Kind -> Kind ; -- P K | K that is P
|
KProp : Property -> Kind -> Kind ; -- P K | K that is P
|
||||||
KRel : Relation -> Kind ; -- R ---??
|
KFun : Function -> Kind ; -- R ---??
|
||||||
|
|
||||||
IName : Name -> Individual ;
|
IName : Name -> Individual ;
|
||||||
|
|
||||||
@@ -59,6 +68,8 @@ fun
|
|||||||
|
|
||||||
PIs : Individual -> Property ;
|
PIs : Individual -> Property ;
|
||||||
|
|
||||||
|
PRelation : Relation -> Set -> Property ;
|
||||||
|
|
||||||
-- the test lexicon
|
-- the test lexicon
|
||||||
|
|
||||||
cat
|
cat
|
||||||
@@ -68,32 +79,37 @@ fun
|
|||||||
NCountry : Country -> Name ;
|
NCountry : Country -> Name ;
|
||||||
PCountry : Country -> Property ;
|
PCountry : Country -> Property ;
|
||||||
|
|
||||||
Located : Set -> Property ;
|
Located : Relation ;
|
||||||
|
|
||||||
In : Set -> Property ;
|
In : Relation ;
|
||||||
HaveTitleAt : JobTitle -> Set -> Property ;
|
HaveTitleAt : JobTitle -> Relation ;
|
||||||
HaveTitle : JobTitle -> Property ;
|
EmployedAt : Set -> Relation ;
|
||||||
Employed : Set -> Property ;
|
HaveTitle : Relation ;
|
||||||
|
Employed : Relation ;
|
||||||
|
|
||||||
Named : Name -> Property ;
|
Named : Name -> Property ;
|
||||||
|
|
||||||
Start : Name -> Property ;
|
Start : Name -> Property ;
|
||||||
|
|
||||||
Organization : Kind ;
|
Organization : Kind ;
|
||||||
|
Company : Kind ;
|
||||||
Place : Kind ;
|
Place : Kind ;
|
||||||
Person : Kind ;
|
Person : Kind ;
|
||||||
|
|
||||||
Location : Relation ;
|
Location : Function ;
|
||||||
Region : Relation ;
|
Region : Function ;
|
||||||
Subregion : Relation ;
|
Subregion : Function ;
|
||||||
|
|
||||||
USA : Country ;
|
USA : Country ;
|
||||||
California : Country ;
|
California : Country ;
|
||||||
Bulgaria : Country ;
|
Bulgaria : Country ;
|
||||||
OblastSofiya : Name ;
|
OblastSofiya : Name ;
|
||||||
|
|
||||||
RName : Relation ;
|
FName : Function ;
|
||||||
RNickname : Relation ;
|
FNickname : Function ;
|
||||||
RJobTitle : Relation ;
|
FJobTitle : Function ;
|
||||||
|
|
||||||
|
SJobTitle : JobTitle -> Set ; -- a programmer
|
||||||
|
|
||||||
CEO : JobTitle ;
|
CEO : JobTitle ;
|
||||||
ChiefInformationOfficer : JobTitle ;
|
ChiefInformationOfficer : JobTitle ;
|
||||||
|
|||||||
@@ -15,9 +15,11 @@ lincat
|
|||||||
Query = Utt ;
|
Query = Utt ;
|
||||||
Answer = Cl ; -- Utt ;
|
Answer = Cl ; -- Utt ;
|
||||||
Set = NP ;
|
Set = NP ;
|
||||||
Relation = {cn : CN ; prep : Prep} ;
|
Interrogative = IP ;
|
||||||
|
Function = {cn : CN ; prep : Prep} ;
|
||||||
Kind = CN ;
|
Kind = CN ;
|
||||||
Property = {ap : AP ; vp : VP} ;
|
Property = {ap : AP ; vp : VP} ;
|
||||||
|
Relation = {ap : AP ; vp : VP ; prep : Prep} ;
|
||||||
Individual = NP ;
|
Individual = NP ;
|
||||||
Name = NP ;
|
Name = NP ;
|
||||||
[Individual] = [NP] ;
|
[Individual] = [NP] ;
|
||||||
@@ -39,19 +41,34 @@ lin
|
|||||||
| mkUtt (mkQS (mkQCl (L.CompIP (L.IdetIP (mkIDet which_IQuant))) ss))
|
| mkUtt (mkQS (mkQCl (L.CompIP (L.IdetIP (mkIDet which_IQuant))) ss))
|
||||||
| mkUtt ss ;
|
| mkUtt ss ;
|
||||||
|
|
||||||
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 =
|
QWhere s =
|
||||||
mkUtt (mkQS (mkQCl where_IAdv s))
|
mkUtt (mkQS (mkQCl where_IAdv s))
|
||||||
| mkUtt (mkQS (mkQCl where_IAdv (mkCl s (mkA "located" | mkA "situated")))) ;
|
| mkUtt (mkQS (mkQCl where_IAdv (mkCl s (mkA "located" | mkA "situated")))) ;
|
||||||
QRel r s =
|
QWhat i p = mkUtt (mkQS (mkQCl i p.vp)) ;
|
||||||
|
QWhatWhat i j p = mkUtt (mkQS (QuestQVP i (AdvQVP p.vp (mkIAdv p.prep j)))) ;
|
||||||
|
QWhatWhere i p = mkUtt (mkQS (QuestQVP i (AdvQVP p.vp where_IAdv))) ;
|
||||||
|
QRelWhere s p = mkUtt (mkQS (mkQCl where_IAdv (mkCl s p.vp))) ;
|
||||||
|
|
||||||
|
QFun r s =
|
||||||
mkUtt
|
mkUtt
|
||||||
(mkImp (mkVP give_V3 (mkNP and_Conj s (mkNP (mkQuant they_Pron) plNum r.cn)) (mkNP i_Pron)))
|
(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 (mkIP what_IQuant plNum r.cn) s have_V2))
|
||||||
| mkUtt (mkQS (mkQCl whatSg_IP
|
| mkUtt (mkQS (mkQCl whatSg_IP
|
||||||
(mkClSlash (mkClSlash s have_V2) (mkAdv as_Prep (mkNP aPl_Det r.cn))))) ;
|
(mkClSlash (mkClSlash s have_V2) (mkAdv as_Prep (mkNP aPl_Det r.cn))))) ;
|
||||||
|
|
||||||
|
QFunPair s f =
|
||||||
|
let
|
||||||
|
ss0 : NP = s
|
||||||
|
| mkNP (mkNP thePl_Det L.name_N) (mkAdv possess_Prep s) ;
|
||||||
|
ss : NP = mkNP and_Conj ss0 (mkNP (mkQuant they_Pron) plNum f.cn)
|
||||||
|
| mkNP ss0 (mkAdv with_Prep (mkNP (mkQuant they_Pron) plNum f.cn))
|
||||||
|
in
|
||||||
|
mkUtt (mkImp (mkVP give_V3 ss (mkNP i_Pron)))
|
||||||
|
| mkUtt (mkQS (mkQCl (L.CompIP whatPl_IP) ss))
|
||||||
|
| mkUtt (mkQS (mkQCl (L.CompIP (L.IdetIP (mkIDet which_IQuant))) ss))
|
||||||
|
| mkUtt ss ;
|
||||||
|
|
||||||
QInfo s =
|
QInfo s =
|
||||||
let
|
let
|
||||||
info : NP = mkNP (all_NP | (mkNP information_N)) (mkAdv about_Prep s) ;
|
info : NP = mkNP (all_NP | (mkNP information_N)) (mkAdv about_Prep s) ;
|
||||||
@@ -72,7 +89,7 @@ lin
|
|||||||
AProp s p = (mkCl s p.vp) ;
|
AProp s p = (mkCl s p.vp) ;
|
||||||
|
|
||||||
SAll k = mkNP all_Predet (mkNP aPl_Det k) | mkNP thePl_Det k ;
|
SAll k = mkNP all_Predet (mkNP aPl_Det k) | mkNP thePl_Det k ;
|
||||||
SRel s r = mkNP (GenNP s) plNum r.cn | mkNP (GenNP s) sgNum r.cn ;
|
SFun s r = mkNP (GenNP s) plNum r.cn | mkNP (GenNP s) sgNum r.cn ;
|
||||||
SOne k = mkNP n1_Numeral k ;
|
SOne k = mkNP n1_Numeral k ;
|
||||||
SIndef k = mkNP a_Det k ;
|
SIndef k = mkNP a_Det k ;
|
||||||
SDef k = mkNP the_Det k ;
|
SDef k = mkNP the_Det k ;
|
||||||
@@ -81,20 +98,27 @@ lin
|
|||||||
SInd i = i ;
|
SInd i = i ;
|
||||||
SInds is = mkNP and_Conj is ;
|
SInds is = mkNP and_Conj is ;
|
||||||
|
|
||||||
KRelSet r s =
|
IWhich k =
|
||||||
|
mkIP what_IQuant (sgNum | plNum) k
|
||||||
|
| mkIP which_IQuant (sgNum | plNum) k ;
|
||||||
|
|
||||||
|
IWho = whoSg_IP | whoPl_IP ;
|
||||||
|
IWhat = whatSg_IP | whatPl_IP ;
|
||||||
|
|
||||||
|
KFunSet r s =
|
||||||
mkCN r.cn (mkAdv r.prep s) ;
|
mkCN r.cn (mkAdv r.prep s) ;
|
||||||
|
|
||||||
KRelsSet r q s =
|
KFunsSet r q s =
|
||||||
mkCN (ConjCN and_Conj (BaseCN r.cn q.cn)) (mkAdv r.prep s) ;
|
mkCN (ConjCN and_Conj (BaseCN r.cn q.cn)) (mkAdv r.prep s) ;
|
||||||
|
|
||||||
KRelKind k r s =
|
KFunKind k r s =
|
||||||
mkCN k (mkRS (mkRCl that_RP (mkVP (mkNP aPl_Det (mkCN r.cn (mkAdv r.prep 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)) ;
|
KFunPair k r = mkCN k (mkAdv with_Prep (mkNP (mkQuant they_Pron) plNum r.cn)) ;
|
||||||
KProp p k =
|
KProp p k =
|
||||||
mkCN p.ap k
|
mkCN p.ap k
|
||||||
| mkCN k (mkRS (mkRCl that_RP p.vp)) ;
|
| mkCN k (mkRS (mkRCl that_RP p.vp)) ;
|
||||||
KRel r = r.cn ;
|
KFun r = r.cn ;
|
||||||
|
|
||||||
IName n = n ;
|
IName n = n ;
|
||||||
|
|
||||||
@@ -103,6 +127,11 @@ lin
|
|||||||
|
|
||||||
PIs i = propVP (mkVP i) ;
|
PIs i = propVP (mkVP i) ;
|
||||||
|
|
||||||
|
PRelation r s = {
|
||||||
|
ap = AdvAP r.ap (mkAdv r.prep s) ;
|
||||||
|
vp = mkVP r.vp (mkAdv r.prep s)
|
||||||
|
} ;
|
||||||
|
|
||||||
BaseIndividual = mkListNP ;
|
BaseIndividual = mkListNP ;
|
||||||
ConsIndividual = mkListNP ;
|
ConsIndividual = mkListNP ;
|
||||||
|
|
||||||
@@ -125,7 +154,7 @@ oper
|
|||||||
-- lexical constructors
|
-- lexical constructors
|
||||||
mkName : Str -> NP =
|
mkName : Str -> NP =
|
||||||
\s -> mkNP (mkPN s) ;
|
\s -> mkNP (mkPN s) ;
|
||||||
mkRelation : Str -> {cn : CN ; prep : Prep} =
|
mkFunction : Str -> {cn : CN ; prep : Prep} =
|
||||||
\s -> {cn = mkCN (mkN s) ; prep = possess_Prep} ;
|
\s -> {cn = mkCN (mkN s) ; prep = possess_Prep} ;
|
||||||
|
|
||||||
propAP : AP -> {ap : AP ; vp : VP} = \ap -> {
|
propAP : AP -> {ap : AP ; vp : VP} = \ap -> {
|
||||||
@@ -138,9 +167,22 @@ oper
|
|||||||
vp = vp
|
vp = vp
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
relAP : AP -> Prep -> {ap : AP ; vp : VP ; prep : Prep} = \ap,p -> {
|
||||||
|
ap = ap ;
|
||||||
|
vp = mkVP ap ;
|
||||||
|
prep = p
|
||||||
|
} ;
|
||||||
|
|
||||||
|
relVP : VP -> Prep -> {ap : AP ; vp : VP ; prep : Prep} = \vp,p -> {
|
||||||
|
ap = PartVP vp ;
|
||||||
|
vp = vp ;
|
||||||
|
prep = p
|
||||||
|
} ;
|
||||||
|
|
||||||
propCalled : NP -> {ap : AP ; vp : VP} = \i ->
|
propCalled : NP -> {ap : AP ; vp : VP} = \i ->
|
||||||
propAP (mkAP (also_AdA | otherwise_AdA) (mkAP (mkA2 called_A []) i)) ;
|
propAP (mkAP (also_AdA | otherwise_AdA) (mkAP (mkA2 called_A []) i)) ;
|
||||||
|
|
||||||
|
noPrep : Prep = mkPrep [] ;
|
||||||
|
|
||||||
-- lexicon
|
-- lexicon
|
||||||
|
|
||||||
@@ -151,65 +193,63 @@ lin
|
|||||||
NCountry c = c.np ;
|
NCountry c = c.np ;
|
||||||
PCountry c = propAP (mkAP c.a) ;
|
PCountry c = propAP (mkAP c.a) ;
|
||||||
|
|
||||||
Located i = propAP (
|
Located =
|
||||||
mkAP (mkA2 (mkA "located") in_Prep) i
|
relAP (mkAP (mkA "located")) in_Prep
|
||||||
| mkAP (mkA2 (mkA "situated") in_Prep) i
|
| relAP (mkAP (mkA "situated")) in_Prep
|
||||||
) ;
|
;
|
||||||
|
|
||||||
In i = propVP (mkVP (mkAdv in_Prep i)) ;
|
In = relVP UseCopula in_Prep ;
|
||||||
|
|
||||||
Employed i = propAP (
|
Employed =
|
||||||
mkAP (mkA2 (mkA "employed") by8agent_Prep) i
|
relAP (mkAP (mkA "employed")) by8agent_Prep
|
||||||
| mkAP (mkA2 (mkA "paid") by8agent_Prep) i
|
| relAP (mkAP (mkA "paid")) by8agent_Prep
|
||||||
| mkAP (mkA2 (mkA "active") at_Prep) i
|
| relAP (mkAP (mkA "active")) at_Prep
|
||||||
| mkAP (mkA2 (mkA "professionally active") at_Prep) i
|
| relAP (mkAP (mkA "professionally active")) at_Prep
|
||||||
)
|
| relVP (mkVP (mkV "work")) at_Prep
|
||||||
|
|
| relVP (mkVP (mkV "collaborate")) in_Prep
|
||||||
propVP (
|
;
|
||||||
mkVP (mkV2 (mkV "work") at_Prep) i
|
|
||||||
| mkVP (mkV2 (mkV "collaborate") in_Prep) i
|
|
||||||
) ;
|
|
||||||
|
|
||||||
HaveTitle t =
|
HaveTitle =
|
||||||
propAP (
|
relAP (mkAP (mkA "employed")) as_Prep
|
||||||
mkAP (mkA2 (mkA "employed") as_Prep) (mkNP t)
|
--- | relVP UseCopula noPrep
|
||||||
)
|
| relVP (mkVP (mkV "work")) as_Prep
|
||||||
|
|
| relVP (mkVP have_V2 (mkNP the_Det (mkCN (mkN2 (mkN "title"))))) possess_Prep
|
||||||
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 =
|
EmployedAt s =
|
||||||
propAP (
|
relAP (mkAP (mkA2 (mkA "employed") at_Prep) s) as_Prep
|
||||||
mkAP (mkA2 (mkA "employed") as_Prep) (mkNP (mkNP t) (mkAdv at_Prep i))
|
| relAP (mkAP (mkA2 (mkA "employed") by8agent_Prep) s) as_Prep
|
||||||
)
|
| relVP (mkVP (mkV2 (mkV "work") at_Prep) s) as_Prep
|
||||||
|
|
;
|
||||||
propVP (
|
|
||||||
mkVP (mkVP (mkNP a_Det t)) (mkAdv at_Prep i)
|
HaveTitleAt t =
|
||||||
| mkVP (mkVP (mkV2 (mkV "work") as_Prep) (mkNP t)) (mkAdv at_Prep i)
|
relAP (mkAP (mkA2 (mkA "employed") as_Prep) (mkNP t)) at_Prep
|
||||||
-- | mkVP (mkVP have_V2 (mkNP the_Det (mkCN (mkN2 (mkN "title")) (mkNP t))))
|
| relAP (mkAP (mkA2 (mkA "employed") as_Prep) (mkNP t)) by8agent_Prep
|
||||||
-- (mkAdv at_Prep i)
|
| relVP (mkVP (mkNP a_Det t)) at_Prep
|
||||||
) ;
|
| relVP (mkVP (mkV2 (mkV "work") as_Prep) (mkNP t)) at_Prep
|
||||||
|
| relVP (mkVP have_V2 (mkNP the_Det (mkCN (mkN2 (mkN "title")) (mkNP t)))) at_Prep
|
||||||
|
;
|
||||||
|
|
||||||
Named n = propAP (mkAP (mkA2 (mkA "named") []) n) ;
|
Named n = propAP (mkAP (mkA2 (mkA "named") []) n) ;
|
||||||
Start n = propVP (mkVP (mkV2 "start" with_Prep) n) ;
|
Start n = propVP (mkVP (mkV2 "start" with_Prep) n) ;
|
||||||
|
|
||||||
Organization = mkCN (mkN "organization") ;
|
Organization = mkCN (mkN "organization") ;
|
||||||
|
Company = mkCN (mkN "company") ;
|
||||||
Place = mkCN (mkN "place") ;
|
Place = mkCN (mkN "place") ;
|
||||||
Person =
|
Person =
|
||||||
mkCN (mkN "person" "people")
|
mkCN (mkN "person" "people")
|
||||||
| mkCN (mkN "person") ;
|
| mkCN (mkN "person") ;
|
||||||
|
|
||||||
Location = mkRelation "location" ;
|
Location = mkFunction "location" ;
|
||||||
Region = mkRelation "region" ;
|
Region = mkFunction "region" ;
|
||||||
Subregion = mkRelation "subregion" | mkRelation "sub-region" ;
|
Subregion = mkFunction "subregion" | mkFunction "sub-region" ;
|
||||||
RName = mkRelation "name" ;
|
FName = mkFunction "name" ;
|
||||||
RNickname = mkRelation "nickname" ;
|
FNickname = mkFunction "nickname" ;
|
||||||
RJobTitle = mkRelation "job title" | mkRelation "job" | mkRelation "position" |
|
FJobTitle = mkFunction "job title" | mkFunction "job" | mkFunction "position" |
|
||||||
mkRelation "appointment" | mkRelation "job position" | mkRelation "mandate" |
|
mkFunction "appointment" | mkFunction "job position" | mkFunction "mandate" |
|
||||||
mkRelation "title" ;
|
mkFunction "title" | mkFunction "capacity" ;
|
||||||
|
|
||||||
|
SJobTitle t = mkNP a_Det t ;
|
||||||
|
|
||||||
USA = mkCountry "USA" "American" ;
|
USA = mkCountry "USA" "American" ;
|
||||||
Bulgaria = mkCountry "Bulgaria" "Bulgarian" ;
|
Bulgaria = mkCountry "Bulgaria" "Bulgarian" ;
|
||||||
|
|||||||
57
examples/query/README
Normal file
57
examples/query/README
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
Copyright (c) 2010 Aarne Ranta, under LGPL(3).
|
||||||
|
Part of MOLTO Project, WP 4.
|
||||||
|
|
||||||
|
Query language, based on the corpus from Ontotext.
|
||||||
|
|
||||||
|
Purpose: natural language queries to an ontology database.
|
||||||
|
|
||||||
|
Work in progress:
|
||||||
|
- 19 June parsing 28% 160/562
|
||||||
|
- 17 June 2010 first version, parsing under 10%
|
||||||
|
|
||||||
|
|
||||||
|
The corpus contains misspellings and ungrammatical sentences; these will (mostly) not
|
||||||
|
be covered by the grammar.
|
||||||
|
|
||||||
|
Test:
|
||||||
|
|
||||||
|
-- start GF with the grammar; notice that lib/present/ must have latest Eng libraries,
|
||||||
|
-- which can be provided by 'runghc Make present lang api langs=Eng' in lib/src/
|
||||||
|
% gf QueryEng.gf
|
||||||
|
-- parse a sentence and see all variants
|
||||||
|
> "p "Bulgarian people working at Google" | l -all
|
||||||
|
|
||||||
|
Regression test:
|
||||||
|
|
||||||
|
-- run the parser on the corpus
|
||||||
|
% gf QueryEng.gf <test.gfs > test.results8
|
||||||
|
-- compute the number of sentences not covered
|
||||||
|
% grep "no tree" test.results8 | wc
|
||||||
|
|
||||||
|
|
||||||
|
Semantics: generic logical semantics, that could be mapped to many query languages.
|
||||||
|
The denotations of the main categories are, assuming a domain of individuals:
|
||||||
|
|
||||||
|
Set ; P(P(D)) (generalized quantifier) -- the set requested, e.g. "all persons"
|
||||||
|
Function ; D -> P(D) -- something of something, e.g. "subregion of Bulgaria"
|
||||||
|
Kind ; P(D) -- type of things, e.g. "person"
|
||||||
|
Relation ; D -> D -> T -- relation between things,e.g. "employed at"
|
||||||
|
Property ; D -> T -- property of things, e.g. "employed at Google"
|
||||||
|
Individual ; D -- one entity, e.g. "Google"
|
||||||
|
Name ; D -- person, company... e.g. "Eric Schmidt"
|
||||||
|
|
||||||
|
|
||||||
|
Characteristics:
|
||||||
|
- simple AST's, lots of variants (easily hundreds per query)
|
||||||
|
- semantic overgeneration, e.g. "Google works at Larry Page"
|
||||||
|
- some ambiguities, e.g.
|
||||||
|
|
||||||
|
> give me the organizations and their locations
|
||||||
|
MQuery (QFun Location (SAll Organization))
|
||||||
|
MQuery (QFunPair (SAll Organization) Location)
|
||||||
|
|
||||||
|
Maybe harmless?
|
||||||
|
|
||||||
|
Resource grammar was not quite enough; added for instance multiple interrogatives
|
||||||
|
("who is employed as what where") in Extra and ExtraEng
|
||||||
|
|
||||||
Reference in New Issue
Block a user