Commit bd0de0b5df684cb5aa8f591c4763d79406208ea8
1 parent
28b17074
Uzupełnienie zbioru selektorów
Showing
11 changed files
with
52 additions
and
10 deletions
LCGlexicon/ENIAM_LCGlexicon.ml
... | ... | @@ -251,10 +251,12 @@ let make_node id orth lemma pos syntax weight cat_list is_raised = |
251 | 251 | | Ctype -> ("CTYPE", SubstVar "ctype") :: attrs |
252 | 252 | | Mode -> ("MODE", SubstVar "mode") :: attrs |
253 | 253 | | Psem -> ("PSEM", SubstVar "psem") :: attrs |
254 | + | Icat -> attrs | |
254 | 255 | | Inumber -> attrs |
255 | 256 | | Igender -> attrs |
256 | 257 | | Iperson -> attrs |
257 | 258 | | Nperson -> attrs |
259 | + | Ncat -> attrs | |
258 | 260 | | Plemma -> attrs |
259 | 261 | | Unumber -> attrs |
260 | 262 | | Ucase -> attrs |
... | ... |
LCGlexicon/ENIAM_LCGlexiconTypes.ml
... | ... | @@ -27,7 +27,7 @@ type categories = {lemma: string; pos: string; pos2: string; cat: string; coerce |
27 | 27 | type selector = |
28 | 28 | Lemma | (*NewLemma |*) Pos | Pos2 | Cat | Coerced | Number | Case | Gender | Person | Grad | Praep | |
29 | 29 | Acm | Aspect | Negation | Mood | Tense | Nsyn | Nsem | Ctype | Mode | Psem | |
30 | - Inumber | Igender | Iperson | Nperson | Plemma | | |
30 | + Icat | Inumber | Igender | Iperson | Nperson | Ncat | Plemma | | |
31 | 31 | Unumber | Ucase | Ugender | Uperson | Amode |
32 | 32 | |
33 | 33 | module OrderedSelector = struct |
... | ... |
LCGlexicon/ENIAMcategoriesPL.ml
... | ... | @@ -431,7 +431,7 @@ let clarify_categories proper cat coerced = function |
431 | 431 | let selector_names = StringSet.of_list [ |
432 | 432 | "lemma";"pos";"pos2";"cat";"coerced";"number";"case";"gender";"person";"grad"; |
433 | 433 | "praep";"acm";"aspect";"negation";"mood";"tense";"nsyn";"nsem";"ctype";"mode";"psem"; |
434 | - "inumber";"igender";"iperson";"nperson";"plemma"; | |
434 | + "icat";"inumber";"igender";"iperson";"nperson";"ncat";"plemma"; | |
435 | 435 | "unumber";"ucase";"ugender";"uperson";"amode"] |
436 | 436 | |
437 | 437 | |
... | ... | @@ -458,10 +458,12 @@ let string_of_selector = function |
458 | 458 | | Ctype -> "ctype" |
459 | 459 | | Mode -> "mode" |
460 | 460 | | Psem -> "psem" |
461 | + | Icat -> "icat" | |
461 | 462 | | Inumber -> "inumber" |
462 | 463 | | Igender -> "igender" |
463 | 464 | | Iperson -> "iperson" |
464 | 465 | | Nperson -> "nperson" |
466 | + | Ncat -> "ncat" | |
465 | 467 | | Plemma -> "plemma" |
466 | 468 | | Unumber -> "unumber" |
467 | 469 | | Ucase -> "ucase" |
... | ... | @@ -497,10 +499,12 @@ let selector_of_string = function |
497 | 499 | | "ctype" -> Ctype |
498 | 500 | | "mode" -> Mode |
499 | 501 | | "psem" -> Psem |
502 | + | "icat" -> Icat | |
500 | 503 | | "inumber" -> Inumber |
501 | 504 | | "igender" -> Igender |
502 | 505 | | "iperson" -> Iperson |
503 | 506 | | "nperson" -> Nperson |
507 | + | "ncat" -> Ncat | |
504 | 508 | | "plemma" -> Plemma |
505 | 509 | | "unumber" -> Unumber |
506 | 510 | | "ucase" -> Ucase |
... | ... |
semantics/ENIAMsemGraph.ml
... | ... | @@ -34,7 +34,7 @@ let rec make_args_list = function |
34 | 34 | let symbols = StringSet.of_list [ |
35 | 35 | "symbol"; "date"; "date-interval"; "hour-minute"; "hour"; "hour-minute-interval"; "hour-interval"; |
36 | 36 | "year"; "year-interval"; "day"; "day-interval"; "day-month"; "day-month-interval"; "month-interval"; "roman"; "roman-interval"; |
37 | - "match-result"; "url"; "email"; "obj-id"; "building-number"; | |
37 | + "match-result"; "url"; "email"; "phone-number"; "obj-id"; "building-number"; | |
38 | 38 | "month-lex"; "day-lex"] |
39 | 39 | |
40 | 40 | let rec get_person = function |
... | ... | @@ -172,6 +172,7 @@ let create_normal_concept tokens lex_sems t cat coerced = |
172 | 172 | | "GRAD",Val "com" -> {c with c_relations=Tuple[c.c_relations;SingleRelation (Val "com")]} |
173 | 173 | | "GRAD",Val "sup" -> {c with c_relations=Tuple[c.c_relations;SingleRelation (Val "sup")]} |
174 | 174 | | "ASPECT",_ -> c |
175 | + | "CTYPE",_ -> c (* FIXME1: trzeba zaznaczyć pytajność w grafie, CTYPE pojawia się w dwu węzłach *) | |
175 | 176 | (* | "TYPE",Val "int" -> {c with c_quant=Tuple[c.c_quant;Val "interrogative"]} *) |
176 | 177 | | "TYPE",_ -> c (* FIXME *) |
177 | 178 | | "PERS",_ -> c |
... | ... | @@ -273,13 +274,19 @@ let create_normal_concept tokens lex_sems t cat coerced = |
273 | 274 | make_relation t (Context cx) else |
274 | 275 | if t.lemma = "<root>" then t.args else |
275 | 276 | if t.lemma = "<merge>" then RemoveRelation("null","",t.args) else |
276 | - if t.pos = "interp" && t.lemma = "?" && t.args = Dot then SingleRelation(Val "int") else | |
277 | + (* if t.pos = "interp" && t.lemma = "?" && t.args = Dot then SingleRelation(Val "int") else *) | |
278 | + if t.pos = "interp" && t.lemma = "?" then | |
279 | + make_relation t (AddSingleRelation(Val "int",RemoveRelation("CORE","",t.args))) else (* FIXME1: to powinno tworzyć kontekst i zaznaczać ze jest interrogative *) | |
277 | 280 | if t.pos = "interp" && t.lemma = ":" then |
278 | 281 | make_relation t (RemoveRelation("CORE","",t.args)) else |
279 | 282 | if t.pos = "interp" && t.lemma = "</sentence>" then |
280 | 283 | let l = (*List.rev*) (make_args_list t.args) in |
281 | 284 | Xlist.fold (List.tl l) (RemoveRelation("null","",List.hd l)) (fun t s -> AddRelation(t,"Next","Clause",RemoveRelation("null","",s))) else |
282 | 285 | if t.pos = "interp" && t.lemma = "<sentence>" then t.args else |
286 | + if t.pos = "interp" && t.lemma = "</query>" then | |
287 | + let l = (*List.rev*) (make_args_list t.args) in | |
288 | + Xlist.fold (List.tl l) (List.hd l) (fun t s -> AddRelation(t,"Next","Sentence",s)) else | |
289 | + if t.pos = "interp" && t.lemma = "<query>" then t.args else | |
283 | 290 | (* if t.pos = "interp" && t.lemma = "”s" then |
284 | 291 | let l = List.rev (make_args_list t.args) in |
285 | 292 | 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 = |
340 | 347 | | "NEGATION",s -> t,("NEGATION",s) :: attrs,cat,coerced |
341 | 348 | | "MOOD",s -> t,("MOOD",s) :: attrs,cat,coerced |
342 | 349 | | "TENSE",s -> t,("TENSE",s) :: attrs,cat,coerced |
350 | + | "CTYPE",s -> t,("CTYPE",s) :: attrs,cat,coerced | |
343 | 351 | | "controller",s -> t,("controller",s) :: attrs,cat,coerced |
344 | 352 | | "controllee",s -> t,("controllee",s) :: attrs,cat,coerced |
345 | 353 | | "coref",s -> t,attrs,cat,coerced |
... | ... | @@ -388,6 +396,7 @@ let rec make_tree_rec references = function |
388 | 396 | | SingleRelation r -> SingleRelation r |
389 | 397 | (* | TripleRelation(r,a,s,t) -> TripleRelation(r,a,make_tree_rec references s,make_tree_rec references t) *) |
390 | 398 | | AddRelation(t,r,a,s) -> AddRelation(make_tree_rec references t,r,a,make_tree_rec references s) |
399 | + | AddSingleRelation(r,s) -> AddSingleRelation(r,make_tree_rec references s) | |
391 | 400 | | RemoveRelation(r,a,t) -> RemoveRelation(r,a,make_tree_rec references t) |
392 | 401 | | SetContextName(s,t) -> SetContextName(s,make_tree_rec references t) |
393 | 402 | | CreateContext(s,t) -> CreateContext(s,make_tree_rec references t) |
... | ... | @@ -414,6 +423,7 @@ let rec validate_translation r = function |
414 | 423 | | SingleRelation _ -> () |
415 | 424 | (* | TripleRelation(_,_,s,t) -> validate_translation r s; validate_translation r t *) |
416 | 425 | | AddRelation(t,_,_,s) -> validate_translation r t; validate_translation r s |
426 | + | AddSingleRelation(_,s) -> validate_translation r s | |
417 | 427 | | RemoveRelation(_,_,t) -> validate_translation r t |
418 | 428 | | SetContextName(s,t) -> validate_translation r t |
419 | 429 | | CreateContext(s,t) -> validate_translation r t |
... | ... | @@ -508,6 +518,13 @@ let rec reduce_tree = function |
508 | 518 | (* | TripleRelation(r,a,s,t) -> TripleRelation(r,a,reduce_tree s,reduce_tree t) *) |
509 | 519 | (* | AddRelation(Concept c,r,a,s) -> reduce_tree (Concept{c with c_relations=Tuple[Relation(Val r,Val a,s);c.c_relations]}) |
510 | 520 | | AddRelation(Context c,r,a,s) -> reduce_tree (Context{c with cx_relations=Tuple[Relation(Val r,Val a,s);c.cx_relations]})*) |
521 | + | AddSingleRelation(r,t) -> | |
522 | + (match reduce_tree t with | |
523 | + Concept t -> Concept{t with c_relations=Tuple[t.c_relations;SingleRelation r]} | |
524 | + | Context({cx_sense=Val "czy"} as t) -> Context t | |
525 | + | Context({cx_sense=Val "jaki"} as t) -> Context t | |
526 | + | Context({cx_sense=Dot} as t) -> Context{t with cx_sense=Val "czy"} | |
527 | + | t -> AddSingleRelation(r,t)) | |
511 | 528 | | AddRelation(t,r,a,s) -> simplify_tree_add_relation r a (reduce_tree s) (reduce_tree t) |
512 | 529 | (* let t = reduce_tree t in |
513 | 530 | let s = reduce_tree s in |
... | ... |
semantics/ENIAMsemGraphOf.ml
... | ... | @@ -270,6 +270,13 @@ let rec print_graph2_rec file edge_rev edge_label edge_style edge_head upper = f |
270 | 270 | let _ = print_graph2_rec file false "" "" "" id t in |
271 | 271 | let _ = print_graph2_rec file false "" "" "" id s in |
272 | 272 | id |
273 | + | AddSingleRelation(role,t) -> | |
274 | + let id = !id_counter in | |
275 | + incr id_counter; | |
276 | + fprintf file " %d [shape=circle,label=\"AddSingleRelation\\n%s\"]\n" id (ENIAMsemStringOf.linear_term 0 role); | |
277 | + print_edge2 file edge_rev edge_label edge_style edge_head "" upper id; | |
278 | + let _ = print_graph2_rec file false "" "" "" id t in | |
279 | + id | |
273 | 280 | | RemoveRelation(role,role_attr,t) -> |
274 | 281 | let id = !id_counter in |
275 | 282 | incr id_counter; |
... | ... |
semantics/ENIAMsemLatexOf.ml
... | ... | @@ -75,6 +75,7 @@ let rec linear_term c = function |
75 | 75 | | SingleRelation r -> "{\\bf singlerelation}(" ^ linear_term 0 r ^ ")" |
76 | 76 | (* | TripleRelation(r,a,c,t) -> "{\\bf triplerelation}(" ^ (*linear_term 0*) r ^ "," ^ (*linear_term 0*) a ^ "," ^ linear_term 0 c ^ "," ^ linear_term 0 t ^ ")" *) |
77 | 77 | | AddRelation(t,r,a,s) -> "{\\bf addrelation}(" ^ linear_term 0 t ^ "," ^ r ^ "," ^ a ^ "," ^ linear_term 0 s ^ ")" |
78 | + | AddSingleRelation(r,s) -> "{\\bf addrelation}(" ^ linear_term 0 r ^ "," ^ linear_term 0 s ^ ")" | |
78 | 79 | | RemoveRelation(r,a,t) -> "{\\bf removerelation}(" ^ r ^ "," ^ a ^ "," ^ linear_term 0 t ^ ")" |
79 | 80 | | SetContextName(s,t) -> "{\\bf setcontextname}(" ^ linear_term 0 s ^ "," ^ linear_term 0 t ^ ")" |
80 | 81 | | CreateContext(s,t) -> "{\\bf createcontext}(" ^ linear_term 0 (Context s) ^ "," ^ linear_term 0 t ^ ")" |
... | ... |
semantics/ENIAMsemLexicon.ml
... | ... | @@ -45,7 +45,7 @@ let parse_multi p = function |
45 | 45 | | tokens -> tokens,p |
46 | 46 | |
47 | 47 | let parse_morf p = function |
48 | - [T "1"] -> {p with is_necessary=Opt} | |
48 | + [T "1"] -> if p.is_necessary=Multi then p else {p with is_necessary=Opt} | |
49 | 49 | | tokens -> |
50 | 50 | let l = Xlist.map (try Lexer.split_symbol (T "*") [] tokens with _ -> failwith "parse_morf: split_symbol *") (function |
51 | 51 | [T s] -> Atom s |
... | ... |
semantics/ENIAMsemStringOf.ml
... | ... | @@ -52,6 +52,7 @@ let rec linear_term c = function |
52 | 52 | | SingleRelation r -> "singlerelation(" ^ linear_term 0 r ^ ")" |
53 | 53 | (* | TripleRelation(r,a,c,t) -> "triplerelation(" ^ r ^ "," ^ a ^ "," ^ linear_term 0 c ^ "," ^ linear_term 0 t ^ ")" *) |
54 | 54 | | AddRelation(t,r,a,s) -> "addrelation(" ^ linear_term 0 t ^ "," ^ r ^ "," ^ a ^ "," ^ linear_term 0 s ^ ")" |
55 | + | AddSingleRelation(r,s) -> "addsinglerelation(" ^ linear_term 0 r ^ "," ^ linear_term 0 s ^ ")" | |
55 | 56 | | RemoveRelation(r,a,t) -> "removerelation(" ^ r ^ "," ^ a ^ "," ^ linear_term 0 t ^ ")" |
56 | 57 | | SetContextName(s,t) -> "setcontextname(" ^ linear_term 0 s ^ "," ^ linear_term 0 t ^ ")" |
57 | 58 | | CreateContext(s,t) -> "createcontext(" ^ linear_term 0 (Context s) ^ "," ^ linear_term 0 t ^ ")" |
... | ... |
semantics/ENIAMsemTypes.ml
... | ... | @@ -72,7 +72,8 @@ and linear_term = |
72 | 72 | | RevRelation of string * string * linear_term (* role * role_attr * concept *) |
73 | 73 | | SingleRelation of linear_term |
74 | 74 | (* | TripleRelation of string * string * linear_term * linear_term (* role * role_attr * concept *) *) |
75 | - | AddRelation of linear_term * string * string * linear_term (* nadrządnik * role * role_attr * podrzędnik *) | |
75 | + | AddRelation of linear_term * string * string * linear_term (* nadrzędnik * role * role_attr * podrzędnik *) | |
76 | + | AddSingleRelation of linear_term * linear_term (* role * podrzędnik *) | |
76 | 77 | | RemoveRelation of string * string * linear_term |
77 | 78 | | SetContextName of linear_term * linear_term (* sense * concept *) |
78 | 79 | | CreateContext of context * linear_term (* context * args *) |
... | ... |
semantics/ENIAMsemValence.ml
... | ... | @@ -220,7 +220,9 @@ let string_of_arg arg = |
220 | 220 | String.concat ", " (Xlist.map arg (fun ((arg_symbol,dir),t) -> (string_of_argdir dir) ^ arg_symbol ^ ":" ^ ENIAM_LCGstringOf.linear_term 0 t)) |
221 | 221 | |
222 | 222 | let string_of_position p = |
223 | - (string_of_argdir p.dir) ^ String.concat "+" (StringSet.to_list p.morfs) | |
223 | + (string_of_argdir p.dir) ^ | |
224 | + (if p.is_multi then "?" else "") ^ | |
225 | + String.concat "+" (StringSet.to_list p.morfs) | |
224 | 226 | |
225 | 227 | let manage_arg p t = |
226 | 228 | 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 |
383 | 385 | let frame = ENIAMsemLexicon.extend_frame phsymbol frame in |
384 | 386 | (* print_endline "passed"; *) |
385 | 387 | (attrs,symbol,frame,Xlist.rev_map frame.positions (translate_position (string_of_int t.id))) :: frames |
386 | - with Not_found -> (*print_endline "rejected";*) frames) in | |
387 | - if frames = [] then failwith "assign_frames_rec: no frame" else | |
388 | + with Not_found -> | |
389 | + (* print_endline "rejected"; *) | |
390 | + frames) in | |
391 | + if frames = [] then failwith ("assign_frames_rec: no frame phsymbol='" ^ phsymbol ^ "' node='" ^ t.lemma ^ "'") else | |
388 | 392 | let prong_attrs = get_prong_attrs t.attrs in |
389 | 393 | let e = ENIAM_LCGreductions.get_variant_label () in |
390 | 394 | 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 |
404 | 408 | ("fopinion",Val (ENIAMwalStringOf.opinion frame.fopinion)) :: |
405 | 409 | ("sopinion",Val (ENIAMwalStringOf.opinion frame.sopinion)) :: attrs; args=args; symbol=symbol}) :: |
406 | 410 | l,n+1))) in |
407 | - 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 | |
411 | + if l = [] then ( | |
412 | + (* print_endline ("assign_frames_rec 4: no frame assingment found for " ^ t.lemma ^ " " ^ ENIAM_LCGstringOf.linear_term 0 t.symbol); *) | |
413 | + raise (NoFrame(t.lemma,ENIAM_LCGstringOf.linear_term 0 t.symbol,visited))) else | |
408 | 414 | Variant(e,l),visited |
409 | 415 | | Variant(e,l) -> |
410 | 416 | let a = ref "" in |
... | ... |
semantics/ENIAMsemXMLof.ml
... | ... | @@ -61,6 +61,9 @@ let rec linear_term = function |
61 | 61 | | AddRelation(t,r,a,s) -> |
62 | 62 | Xml.Element("AddRelation",["role",r;"role_attribute",a], |
63 | 63 | [Xml.Element("",[],[linear_term t]);Xml.Element("",[],[linear_term s])]) |
64 | + | AddSingleRelation(r,s) -> | |
65 | + Xml.Element("AddSingleRelation",[], | |
66 | + [Xml.Element("",[],[linear_term r]);Xml.Element("",[],[linear_term s])]) | |
64 | 67 | | RemoveRelation(r,a,t) -> Xml.Element("RemoveRelation",["role",r;"role_attribute",a],[linear_term t]) |
65 | 68 | | SetContextName(s,t) -> |
66 | 69 | Xml.Element("SetContextName",[],[linear_term s;linear_term t]) |
... | ... |