diff --git a/LCGlexicon/ENIAM_LCGlexicon.ml b/LCGlexicon/ENIAM_LCGlexicon.ml index 85f9a6d..89930b4 100644 --- a/LCGlexicon/ENIAM_LCGlexicon.ml +++ b/LCGlexicon/ENIAM_LCGlexicon.ml @@ -251,10 +251,12 @@ let make_node id orth lemma pos syntax weight cat_list is_raised = | Ctype -> ("CTYPE", SubstVar "ctype") :: attrs | Mode -> ("MODE", SubstVar "mode") :: attrs | Psem -> ("PSEM", SubstVar "psem") :: attrs + | Icat -> attrs | Inumber -> attrs | Igender -> attrs | Iperson -> attrs | Nperson -> attrs + | Ncat -> attrs | Plemma -> attrs | Unumber -> attrs | Ucase -> attrs diff --git a/LCGlexicon/ENIAM_LCGlexiconTypes.ml b/LCGlexicon/ENIAM_LCGlexiconTypes.ml index 9967ea1..4f3dcd7 100644 --- a/LCGlexicon/ENIAM_LCGlexiconTypes.ml +++ b/LCGlexicon/ENIAM_LCGlexiconTypes.ml @@ -27,7 +27,7 @@ type categories = {lemma: string; pos: string; pos2: string; cat: string; coerce type selector = Lemma | (*NewLemma |*) Pos | Pos2 | Cat | Coerced | Number | Case | Gender | Person | Grad | Praep | Acm | Aspect | Negation | Mood | Tense | Nsyn | Nsem | Ctype | Mode | Psem | - Inumber | Igender | Iperson | Nperson | Plemma | + Icat | Inumber | Igender | Iperson | Nperson | Ncat | Plemma | Unumber | Ucase | Ugender | Uperson | Amode module OrderedSelector = struct diff --git a/LCGlexicon/ENIAMcategoriesPL.ml b/LCGlexicon/ENIAMcategoriesPL.ml index 30fbf52..de8275f 100644 --- a/LCGlexicon/ENIAMcategoriesPL.ml +++ b/LCGlexicon/ENIAMcategoriesPL.ml @@ -431,7 +431,7 @@ let clarify_categories proper cat coerced = function let selector_names = StringSet.of_list [ "lemma";"pos";"pos2";"cat";"coerced";"number";"case";"gender";"person";"grad"; "praep";"acm";"aspect";"negation";"mood";"tense";"nsyn";"nsem";"ctype";"mode";"psem"; - "inumber";"igender";"iperson";"nperson";"plemma"; + "icat";"inumber";"igender";"iperson";"nperson";"ncat";"plemma"; "unumber";"ucase";"ugender";"uperson";"amode"] @@ -458,10 +458,12 @@ let string_of_selector = function | Ctype -> "ctype" | Mode -> "mode" | Psem -> "psem" + | Icat -> "icat" | Inumber -> "inumber" | Igender -> "igender" | Iperson -> "iperson" | Nperson -> "nperson" + | Ncat -> "ncat" | Plemma -> "plemma" | Unumber -> "unumber" | Ucase -> "ucase" @@ -497,10 +499,12 @@ let selector_of_string = function | "ctype" -> Ctype | "mode" -> Mode | "psem" -> Psem + | "icat" -> Icat | "inumber" -> Inumber | "igender" -> Igender | "iperson" -> Iperson | "nperson" -> Nperson + | "ncat" -> Ncat | "plemma" -> Plemma | "unumber" -> Unumber | "ucase" -> Ucase diff --git a/semantics/ENIAMsemGraph.ml b/semantics/ENIAMsemGraph.ml index f6ad19a..d471362 100644 --- a/semantics/ENIAMsemGraph.ml +++ b/semantics/ENIAMsemGraph.ml @@ -34,7 +34,7 @@ let rec make_args_list = function let symbols = StringSet.of_list [ "symbol"; "date"; "date-interval"; "hour-minute"; "hour"; "hour-minute-interval"; "hour-interval"; "year"; "year-interval"; "day"; "day-interval"; "day-month"; "day-month-interval"; "month-interval"; "roman"; "roman-interval"; - "match-result"; "url"; "email"; "obj-id"; "building-number"; + "match-result"; "url"; "email"; "phone-number"; "obj-id"; "building-number"; "month-lex"; "day-lex"] let rec get_person = function @@ -172,6 +172,7 @@ let create_normal_concept tokens lex_sems t cat coerced = | "GRAD",Val "com" -> {c with c_relations=Tuple[c.c_relations;SingleRelation (Val "com")]} | "GRAD",Val "sup" -> {c with c_relations=Tuple[c.c_relations;SingleRelation (Val "sup")]} | "ASPECT",_ -> c + | "CTYPE",_ -> c (* FIXME1: trzeba zaznaczyć pytajność w grafie, CTYPE pojawia się w dwu węzłach *) (* | "TYPE",Val "int" -> {c with c_quant=Tuple[c.c_quant;Val "interrogative"]} *) | "TYPE",_ -> c (* FIXME *) | "PERS",_ -> c @@ -273,13 +274,19 @@ let create_normal_concept tokens lex_sems t cat coerced = make_relation t (Context cx) else if t.lemma = "<root>" then t.args else if t.lemma = "<merge>" then RemoveRelation("null","",t.args) else - if t.pos = "interp" && t.lemma = "?" && t.args = Dot then SingleRelation(Val "int") else + (* if t.pos = "interp" && t.lemma = "?" && t.args = Dot then SingleRelation(Val "int") else *) + if t.pos = "interp" && t.lemma = "?" then + make_relation t (AddSingleRelation(Val "int",RemoveRelation("CORE","",t.args))) else (* FIXME1: to powinno tworzyć kontekst i zaznaczać ze jest interrogative *) if t.pos = "interp" && t.lemma = ":" then make_relation t (RemoveRelation("CORE","",t.args)) else if t.pos = "interp" && t.lemma = "</sentence>" then let l = (*List.rev*) (make_args_list t.args) in Xlist.fold (List.tl l) (RemoveRelation("null","",List.hd l)) (fun t s -> AddRelation(t,"Next","Clause",RemoveRelation("null","",s))) else if t.pos = "interp" && t.lemma = "<sentence>" then t.args else + if t.pos = "interp" && t.lemma = "</query>" then + let l = (*List.rev*) (make_args_list t.args) in + Xlist.fold (List.tl l) (List.hd l) (fun t s -> AddRelation(t,"Next","Sentence",s)) else + if t.pos = "interp" && t.lemma = "<query>" then t.args else (* if t.pos = "interp" && t.lemma = "”s" then let l = List.rev (make_args_list t.args) in let x = Xlist.fold (List.tl l) (List.hd l) (fun t s -> AddRelation(RemoveRelation t,"Next","Sentence",RemoveRelation s)) in @@ -340,6 +347,7 @@ let rec translate_node tokens lex_sems t = | "NEGATION",s -> t,("NEGATION",s) :: attrs,cat,coerced | "MOOD",s -> t,("MOOD",s) :: attrs,cat,coerced | "TENSE",s -> t,("TENSE",s) :: attrs,cat,coerced + | "CTYPE",s -> t,("CTYPE",s) :: attrs,cat,coerced | "controller",s -> t,("controller",s) :: attrs,cat,coerced | "controllee",s -> t,("controllee",s) :: attrs,cat,coerced | "coref",s -> t,attrs,cat,coerced @@ -388,6 +396,7 @@ let rec make_tree_rec references = function | SingleRelation r -> SingleRelation r (* | TripleRelation(r,a,s,t) -> TripleRelation(r,a,make_tree_rec references s,make_tree_rec references t) *) | AddRelation(t,r,a,s) -> AddRelation(make_tree_rec references t,r,a,make_tree_rec references s) + | AddSingleRelation(r,s) -> AddSingleRelation(r,make_tree_rec references s) | RemoveRelation(r,a,t) -> RemoveRelation(r,a,make_tree_rec references t) | SetContextName(s,t) -> SetContextName(s,make_tree_rec references t) | CreateContext(s,t) -> CreateContext(s,make_tree_rec references t) @@ -414,6 +423,7 @@ let rec validate_translation r = function | SingleRelation _ -> () (* | TripleRelation(_,_,s,t) -> validate_translation r s; validate_translation r t *) | AddRelation(t,_,_,s) -> validate_translation r t; validate_translation r s + | AddSingleRelation(_,s) -> validate_translation r s | RemoveRelation(_,_,t) -> validate_translation r t | SetContextName(s,t) -> validate_translation r t | CreateContext(s,t) -> validate_translation r t @@ -508,6 +518,13 @@ let rec reduce_tree = function (* | TripleRelation(r,a,s,t) -> TripleRelation(r,a,reduce_tree s,reduce_tree t) *) (* | AddRelation(Concept c,r,a,s) -> reduce_tree (Concept{c with c_relations=Tuple[Relation(Val r,Val a,s);c.c_relations]}) | AddRelation(Context c,r,a,s) -> reduce_tree (Context{c with cx_relations=Tuple[Relation(Val r,Val a,s);c.cx_relations]})*) + | AddSingleRelation(r,t) -> + (match reduce_tree t with + Concept t -> Concept{t with c_relations=Tuple[t.c_relations;SingleRelation r]} + | Context({cx_sense=Val "czy"} as t) -> Context t + | Context({cx_sense=Val "jaki"} as t) -> Context t + | Context({cx_sense=Dot} as t) -> Context{t with cx_sense=Val "czy"} + | t -> AddSingleRelation(r,t)) | AddRelation(t,r,a,s) -> simplify_tree_add_relation r a (reduce_tree s) (reduce_tree t) (* let t = reduce_tree t in let s = reduce_tree s in diff --git a/semantics/ENIAMsemGraphOf.ml b/semantics/ENIAMsemGraphOf.ml index 847eed7..b44ee4e 100644 --- a/semantics/ENIAMsemGraphOf.ml +++ b/semantics/ENIAMsemGraphOf.ml @@ -270,6 +270,13 @@ let rec print_graph2_rec file edge_rev edge_label edge_style edge_head upper = f let _ = print_graph2_rec file false "" "" "" id t in let _ = print_graph2_rec file false "" "" "" id s in id + | AddSingleRelation(role,t) -> + let id = !id_counter in + incr id_counter; + fprintf file " %d [shape=circle,label=\"AddSingleRelation\\n%s\"]\n" id (ENIAMsemStringOf.linear_term 0 role); + print_edge2 file edge_rev edge_label edge_style edge_head "" upper id; + let _ = print_graph2_rec file false "" "" "" id t in + id | RemoveRelation(role,role_attr,t) -> let id = !id_counter in incr id_counter; diff --git a/semantics/ENIAMsemLatexOf.ml b/semantics/ENIAMsemLatexOf.ml index 46842f7..f9bc9fa 100644 --- a/semantics/ENIAMsemLatexOf.ml +++ b/semantics/ENIAMsemLatexOf.ml @@ -75,6 +75,7 @@ let rec linear_term c = function | SingleRelation r -> "{\\bf singlerelation}(" ^ linear_term 0 r ^ ")" (* | TripleRelation(r,a,c,t) -> "{\\bf triplerelation}(" ^ (*linear_term 0*) r ^ "," ^ (*linear_term 0*) a ^ "," ^ linear_term 0 c ^ "," ^ linear_term 0 t ^ ")" *) | AddRelation(t,r,a,s) -> "{\\bf addrelation}(" ^ linear_term 0 t ^ "," ^ r ^ "," ^ a ^ "," ^ linear_term 0 s ^ ")" + | AddSingleRelation(r,s) -> "{\\bf addrelation}(" ^ linear_term 0 r ^ "," ^ linear_term 0 s ^ ")" | RemoveRelation(r,a,t) -> "{\\bf removerelation}(" ^ r ^ "," ^ a ^ "," ^ linear_term 0 t ^ ")" | SetContextName(s,t) -> "{\\bf setcontextname}(" ^ linear_term 0 s ^ "," ^ linear_term 0 t ^ ")" | CreateContext(s,t) -> "{\\bf createcontext}(" ^ linear_term 0 (Context s) ^ "," ^ linear_term 0 t ^ ")" diff --git a/semantics/ENIAMsemLexicon.ml b/semantics/ENIAMsemLexicon.ml index e577a0b..dadc436 100644 --- a/semantics/ENIAMsemLexicon.ml +++ b/semantics/ENIAMsemLexicon.ml @@ -45,7 +45,7 @@ let parse_multi p = function | tokens -> tokens,p let parse_morf p = function - [T "1"] -> {p with is_necessary=Opt} + [T "1"] -> if p.is_necessary=Multi then p else {p with is_necessary=Opt} | tokens -> let l = Xlist.map (try Lexer.split_symbol (T "*") [] tokens with _ -> failwith "parse_morf: split_symbol *") (function [T s] -> Atom s diff --git a/semantics/ENIAMsemStringOf.ml b/semantics/ENIAMsemStringOf.ml index 29cfcc3..82e27d7 100644 --- a/semantics/ENIAMsemStringOf.ml +++ b/semantics/ENIAMsemStringOf.ml @@ -52,6 +52,7 @@ let rec linear_term c = function | SingleRelation r -> "singlerelation(" ^ linear_term 0 r ^ ")" (* | TripleRelation(r,a,c,t) -> "triplerelation(" ^ r ^ "," ^ a ^ "," ^ linear_term 0 c ^ "," ^ linear_term 0 t ^ ")" *) | AddRelation(t,r,a,s) -> "addrelation(" ^ linear_term 0 t ^ "," ^ r ^ "," ^ a ^ "," ^ linear_term 0 s ^ ")" + | AddSingleRelation(r,s) -> "addsinglerelation(" ^ linear_term 0 r ^ "," ^ linear_term 0 s ^ ")" | RemoveRelation(r,a,t) -> "removerelation(" ^ r ^ "," ^ a ^ "," ^ linear_term 0 t ^ ")" | SetContextName(s,t) -> "setcontextname(" ^ linear_term 0 s ^ "," ^ linear_term 0 t ^ ")" | CreateContext(s,t) -> "createcontext(" ^ linear_term 0 (Context s) ^ "," ^ linear_term 0 t ^ ")" diff --git a/semantics/ENIAMsemTypes.ml b/semantics/ENIAMsemTypes.ml index f300e76..caf96a0 100644 --- a/semantics/ENIAMsemTypes.ml +++ b/semantics/ENIAMsemTypes.ml @@ -72,7 +72,8 @@ and linear_term = | RevRelation of string * string * linear_term (* role * role_attr * concept *) | SingleRelation of linear_term (* | TripleRelation of string * string * linear_term * linear_term (* role * role_attr * concept *) *) - | AddRelation of linear_term * string * string * linear_term (* nadrządnik * role * role_attr * podrzędnik *) + | AddRelation of linear_term * string * string * linear_term (* nadrzędnik * role * role_attr * podrzędnik *) + | AddSingleRelation of linear_term * linear_term (* role * podrzędnik *) | RemoveRelation of string * string * linear_term | SetContextName of linear_term * linear_term (* sense * concept *) | CreateContext of context * linear_term (* context * args *) diff --git a/semantics/ENIAMsemValence.ml b/semantics/ENIAMsemValence.ml index 884d422..61927d3 100644 --- a/semantics/ENIAMsemValence.ml +++ b/semantics/ENIAMsemValence.ml @@ -220,7 +220,9 @@ let string_of_arg arg = String.concat ", " (Xlist.map arg (fun ((arg_symbol,dir),t) -> (string_of_argdir dir) ^ arg_symbol ^ ":" ^ ENIAM_LCGstringOf.linear_term 0 t)) let string_of_position p = - (string_of_argdir p.dir) ^ String.concat "+" (StringSet.to_list p.morfs) + (string_of_argdir p.dir) ^ + (if p.is_multi then "?" else "") ^ + String.concat "+" (StringSet.to_list p.morfs) let manage_arg p t = let t = SetAttr("gf",Val (ENIAMwalStringOf.gf p.gf),t) in @@ -383,8 +385,10 @@ let rec assign_frames_rec tokens lex_sems tree arg_symbols visited = function let frame = ENIAMsemLexicon.extend_frame phsymbol frame in (* print_endline "passed"; *) (attrs,symbol,frame,Xlist.rev_map frame.positions (translate_position (string_of_int t.id))) :: frames - with Not_found -> (*print_endline "rejected";*) frames) in - if frames = [] then failwith "assign_frames_rec: no frame" else + with Not_found -> + (* print_endline "rejected"; *) + frames) in + if frames = [] then failwith ("assign_frames_rec: no frame phsymbol='" ^ phsymbol ^ "' node='" ^ t.lemma ^ "'") else let prong_attrs = get_prong_attrs t.attrs in let e = ENIAM_LCGreductions.get_variant_label () in let l,_ = Xlist.fold frames ([],1) (fun (l,n) (attrs,symbol,frame,positions) -> @@ -404,7 +408,9 @@ let rec assign_frames_rec tokens lex_sems tree arg_symbols visited = function ("fopinion",Val (ENIAMwalStringOf.opinion frame.fopinion)) :: ("sopinion",Val (ENIAMwalStringOf.opinion frame.sopinion)) :: attrs; args=args; symbol=symbol}) :: l,n+1))) in - if l = [] then ((*print_endline ("assign_frames_rec 4: no frame assingment found for " ^ t.lemma ^ " " ^ ENIAM_LCGstringOf.linear_term 0 t.symbol);*)raise (NoFrame(t.lemma,ENIAM_LCGstringOf.linear_term 0 t.symbol,visited))) else + if l = [] then ( + (* print_endline ("assign_frames_rec 4: no frame assingment found for " ^ t.lemma ^ " " ^ ENIAM_LCGstringOf.linear_term 0 t.symbol); *) + raise (NoFrame(t.lemma,ENIAM_LCGstringOf.linear_term 0 t.symbol,visited))) else Variant(e,l),visited | Variant(e,l) -> let a = ref "" in diff --git a/semantics/ENIAMsemXMLof.ml b/semantics/ENIAMsemXMLof.ml index 355824a..4f0fe08 100644 --- a/semantics/ENIAMsemXMLof.ml +++ b/semantics/ENIAMsemXMLof.ml @@ -61,6 +61,9 @@ let rec linear_term = function | AddRelation(t,r,a,s) -> Xml.Element("AddRelation",["role",r;"role_attribute",a], [Xml.Element("",[],[linear_term t]);Xml.Element("",[],[linear_term s])]) + | AddSingleRelation(r,s) -> + Xml.Element("AddSingleRelation",[], + [Xml.Element("",[],[linear_term r]);Xml.Element("",[],[linear_term s])]) | RemoveRelation(r,a,t) -> Xml.Element("RemoveRelation",["role",r;"role_attribute",a],[linear_term t]) | SetContextName(s,t) -> Xml.Element("SetContextName",[],[linear_term s;linear_term t])