Commit bc5409b0ee6581bb054c294d731bd66b0475b9b9

Authored by Wojciech Jaworski
1 parent 27ff726e

renderowanie walencji

lexSemantics/ENIAMvalence.ml
... ... @@ -321,7 +321,7 @@ let transform_pers_pos lemma negation mood = function
321 321 (* | PPAS(n,Str,g,a,neg) -> Xlist.map (transform_str negation) (fun case -> PPAS(n,Str,g,a,neg))*)
322 322 | SUBST(n,Part) -> [SUBST(n,Case "gen");SUBST(n,Case "acc")]
323 323 | ADJ(n,Part,g,gr) -> [ADJ(n,Case "gen",g,gr);ADJ(n,Case "acc",g,gr)]
324   - | ADJ(n,CaseAgr,g,gr) as morf -> if lemma = "siedzieć" then [morf] else (print_endline ("transform_pers_pos2: " ^ lemma ^ " " ^ ENIAMwalStringOf.pos morf); [morf]) (* FIXME *)
  324 + | ADJ(n,CaseAgr,g,gr) as morf -> if lemma = "siedzieć" then [ADJ(n,AllAgr,g,gr)] else (print_endline ("transform_pers_pos2: " ^ lemma ^ " " ^ ENIAMwalStringOf.pos morf); [morf]) (* FIXME *)
325 325 | SUBST(_,Case _) as morf -> [morf]
326 326 | PPRON12(_,Case _) as morf -> [morf]
327 327 | PPRON3(_,Case _) as morf -> [morf]
... ... @@ -386,18 +386,22 @@ let transform_preps morf =
386 386  
387 387 let transform_pers_schema lemma negation mood schema =
388 388 Xlist.map schema (fun s ->
389   - {s with morfs =
  389 + {s with morfs = (
390 390 let morfs = List.flatten (Xlist.map s.morfs (transform_comps negation mood)) in
  391 + (* Printf.printf "A %s\n" (String.concat " " (Xlist.map morfs ENIAMwalStringOf.phrase)); *)
391 392 let morfs = List.flatten (Xlist.map morfs transform_preps) in
392   - if s.gf = SUBJ then List.flatten (Xlist.map morfs (function
  393 + (* Printf.printf "B %s\n" (String.concat " " (Xlist.map morfs ENIAMwalStringOf.phrase)); *)
  394 + let morfs = if s.gf = SUBJ then List.flatten (Xlist.map morfs (function
393 395 | E phrase -> Xlist.map (transform_pers_subj_phrase lemma negation mood phrase) (fun phrase -> E phrase)
394 396 | LexArg(id,lex,pos) -> Xlist.map (transform_pers_subj_pos lemma negation mood pos) (fun pos -> LexArg(id,lex,pos))
395 397 | SimpleLexArg(lex,pos) -> Xlist.map (transform_pers_subj_pos lemma negation mood pos) (fun pos -> SimpleLexArg(lex,pos))
396 398 | phrase -> transform_pers_subj_phrase lemma negation mood phrase))
397   - else List.flatten (Xlist.map s.morfs (function
  399 + else List.flatten (Xlist.map morfs (function
398 400 | LexArg(id,lex,pos) -> Xlist.map (transform_pers_pos lemma negation mood pos) (fun pos -> LexArg(id,lex,pos))
399 401 | SimpleLexArg(lex,pos) -> Xlist.map (transform_pers_pos lemma negation mood pos) (fun pos -> SimpleLexArg(lex,pos))
400   - | phrase -> transform_pers_phrase lemma negation mood phrase))})
  402 + | phrase -> transform_pers_phrase lemma negation mood phrase)) in
  403 + (* Printf.printf "C %s\n" (String.concat " " (Xlist.map morfs ENIAMwalStringOf.phrase)); *)
  404 + morfs)})
401 405  
402 406 let transform_nosubj_schema lemma negation mood schema =
403 407 Xlist.map schema (fun s ->
... ... @@ -429,7 +433,7 @@ let transform_ger_schema lemma negation schema = (* FIXME: zakładam, że ger ze
429 433 | LexArg(id,lex,pos) -> Xlist.map (transform_ger_subj_pos lemma negation "gerundial" pos) (fun pos -> LexArg(id,lex,pos))
430 434 | SimpleLexArg(lex,pos) -> Xlist.map (transform_ger_subj_pos lemma negation "gerundial" pos) (fun pos -> SimpleLexArg(lex,pos))
431 435 | phrase -> transform_ger_subj_phrase lemma negation "gerundial" phrase))
432   - else List.flatten (Xlist.map s.morfs (function
  436 + else List.flatten (Xlist.map morfs (function
433 437 | LexArg(id,lex,pos) -> Xlist.map (transform_pers_pos lemma negation "gerundial" pos) (fun pos -> LexArg(id,lex,pos))
434 438 | SimpleLexArg(lex,pos) -> Xlist.map (transform_pers_pos lemma negation "gerundial" pos) (fun pos -> SimpleLexArg(lex,pos))
435 439 | phrase -> transform_pers_phrase lemma negation "gerundial" phrase))})
... ... @@ -446,7 +450,7 @@ let transform_ppas_schema lemma negation mood schema =
446 450 | LexArg(id,lex,SUBST(n,Str)) -> raise Not_found (* FIXME!!! *)
447 451 | SimpleLexArg(lex,SUBST(n,Str)) -> raise Not_found (* FIXME!!! *)
448 452 | phrase -> transform_ppas_subj_phrase lemma negation mood (s.cr <> [] || s.ce <> []) phrase))
449   - else List.flatten (Xlist.map s.morfs (function
  453 + else List.flatten (Xlist.map morfs (function
450 454 | LexArg(id,lex,pos) -> Xlist.map (transform_pers_pos lemma negation mood pos) (fun pos -> LexArg(id,lex,pos))
451 455 | SimpleLexArg(lex,pos) -> Xlist.map (transform_pers_pos lemma negation mood pos) (fun pos -> SimpleLexArg(lex,pos))
452 456 | phrase -> transform_pers_phrase lemma negation mood phrase))})
... ... @@ -482,6 +486,7 @@ let transform_schema pos lemma schema =
482 486 in
483 487 Xlist.map schema (fun s ->
484 488 let morfs = List.flatten (Xlist.map s.morfs (transform_comps NegationUndef "")) in (* FIXME: zależność od trybu warunkowego i negacji *)
  489 + let morfs = List.flatten (Xlist.map morfs transform_preps) in
485 490 {s with morfs=List.flatten (Xlist.map morfs (function
486 491 LexArg(id,lex,pos) -> Xlist.map (pos_fun lemma pos) (fun pos -> LexArg(id,lex,pos))
487 492 | SimpleLexArg(lex,pos) -> Xlist.map (pos_fun lemma pos) (fun pos -> SimpleLexArg(lex,pos))
... ... @@ -562,8 +567,8 @@ let transform_lex_entry pos lemma = function
562 567 | ComprepNPEntry(s,NoRestr,schema) ->
563 568 Xlist.map (transform_entry "comprep" s NegationUndef PredFalse AspectUndef schema) (fun (sel,schema) ->
564 569 sel,ComprepNPEntry(s,NoRestr,schema))
565   - | LexEntry(id,lemma,pos,_,[]) as entry -> [[],entry] (* FIXME *)
566   - | entry -> print_endline ("transform_lex_entry:" ^ ENIAMwalStringOf.lex_entry entry); [[],entry]
  570 + | LexEntry(id,lemma,pos,_,[]) as entry -> [[],entry]
  571 + | entry -> print_endline ("transform_lex_entry:" ^ ENIAMwalStringOf.lex_entry entry); [[],entry]
567 572  
568 573 (*let reduce_frame_negation lexemes = function
569 574 Negation -> StringMap.mem lexemes "nie"
... ... @@ -595,28 +600,30 @@ let rec reduce_frame_atrs_list pos lexemes = function
595 600 | frame :: l -> (if reduce_frame_atrs pos lexemes frame then [frame] else []) @ reduce_frame_atrs_list pos lexemes l
596 601 *)
597 602  
598   -let _ =
599   - let schemata = ENIAMwalReduce.merge_entries ENIAMwalParser.phrases ENIAMwalParser.schemata in
600   - Entries.iter schemata (fun pos lemma (opinion,neg,pred,aspect,schema) ->
  603 +let prepare_all_valence phrases schemata entries =
  604 + let schemata = ENIAMwalReduce.merge_entries phrases schemata in
  605 + Entries.fold schemata Entries.empty (fun schemata pos lemma (opinion,neg,pred,aspect,schema) ->
601 606 match pos with
602   - "noun" -> ignore (transform_entry "subst" lemma neg pred aspect schema)
603   - | "adj" -> ignore (transform_entry "adj" lemma neg pred aspect schema)
604   - | "adv" -> ignore (transform_entry "adv" lemma neg pred aspect schema)
  607 + "noun" -> Entries.add_inc_list schemata "subst" lemma (transform_entry "subst" lemma neg pred aspect schema)
  608 + | "adj" -> Entries.add_inc_list schemata "adj" lemma (transform_entry "adj" lemma neg pred aspect schema)
  609 + | "adv" -> Entries.add_inc_list schemata "adv" lemma (transform_entry "adv" lemma neg pred aspect schema)
605 610 | "verb" ->
606   - ignore (transform_entry "fin" lemma neg pred aspect schema);
607   - ignore (transform_entry "praet" lemma neg pred aspect schema);
608   - ignore (transform_entry "impt" lemma neg pred aspect schema);
609   - ignore (transform_entry "imps" lemma neg pred aspect schema);
610   - ignore (transform_entry "ger" lemma neg pred aspect schema);
611   - ignore (transform_entry "pact" lemma neg pred aspect schema);
612   - ignore (transform_entry "ppas" lemma neg pred aspect schema);
613   - ignore (transform_entry "inf" lemma neg pred aspect schema);
614   - ignore (transform_entry "pcon" lemma neg pred aspect schema);
615   - ignore (transform_entry "pant" lemma neg pred aspect schema);
616   - ignore (transform_entry "bedzie" lemma neg pred aspect schema);
617   - ignore (transform_entry "winien" lemma neg pred aspect schema);
618   - ignore (transform_entry "pred" lemma neg pred aspect schema);
619   - ()
620   - | _ -> failwith "unknown pos");
621   - ignore (Entries.map ENIAMwalParser.entries transform_lex_entry);
622   - ()
  611 + let schemata = Entries.add_inc_list schemata "fin" lemma (transform_entry "fin" lemma neg pred aspect schema) in
  612 + (*Entries.iter schemata (fun _ _ (_,s) -> print_endline ("E " ^ ENIAMwalStringOf.schema s)); *)
  613 + (* let schemata = Entries.add_inc_list schemata "praet" lemma (transform_entry "praet" lemma neg pred aspect schema) in
  614 + let schemata = Entries.add_inc_list schemata "impt" lemma (transform_entry "impt" lemma neg pred aspect schema) in
  615 + let schemata = Entries.add_inc_list schemata "imps" lemma (transform_entry "imps" lemma neg pred aspect schema) in
  616 + let schemata = Entries.add_inc_list schemata "ger" lemma (transform_entry "ger" lemma neg pred aspect schema) in
  617 + let schemata = Entries.add_inc_list schemata "pact" lemma (transform_entry "pact" lemma neg pred aspect schema) in
  618 + let schemata = Entries.add_inc_list schemata "ppas" lemma (transform_entry "ppas" lemma neg pred aspect schema) in
  619 + let schemata = Entries.add_inc_list schemata "inf" lemma (transform_entry "inf" lemma neg pred aspect schema) in
  620 + let schemata = Entries.add_inc_list schemata "pcon" lemma (transform_entry "pcon" lemma neg pred aspect schema) in
  621 + let schemata = Entries.add_inc_list schemata "pant" lemma (transform_entry "pant" lemma neg pred aspect schema) in
  622 + let schemata = Entries.add_inc_list schemata "bedzie" lemma (transform_entry "bedzie" lemma neg pred aspect schema) in
  623 + let schemata = Entries.add_inc_list schemata "winien" lemma (transform_entry "winien" lemma neg pred aspect schema) in
  624 + let schemata = Entries.add_inc_list schemata "pred" lemma (transform_entry "pred" lemma neg pred aspect schema) in*)
  625 + schemata
  626 + | _ -> failwith "unknown pos"),
  627 + (Entries.flatten_map entries transform_lex_entry)
  628 +
  629 +(* let _ = prepare_all_valence ENIAMwalParser.phrases ENIAMwalParser.schemata ENIAMwalParser.entries *)
... ...
lexSemantics/ENIAMvalence2.ml 0 → 100644
  1 +(*
  2 + * ENIAMlexSemantics is a library that assigns tokens with lexicosemantic information.
  3 + * Copyright (C) 2016-2017 Wojciech Jaworski <wjaworski atSPAMfree mimuw dot edu dot pl>
  4 + * Copyright (C) 2016-2017 Institute of Computer Science Polish Academy of Sciences
  5 + *
  6 + * This library is free software: you can redistribute it and/or modify
  7 + * it under the terms of the GNU Lesser General Public License as published by
  8 + * the Free Software Foundation, either version 3 of the License, or
  9 + * (at your option) any later version.
  10 + *
  11 + * This library is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU Lesser General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License
  17 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18 + *)
  19 +
  20 +open ENIAM_LCGtypes
  21 +open ENIAMwalTypes
  22 +
  23 +let arg_of_ctype = function
  24 + Int -> Atom "int"
  25 + | Rel -> Atom "rel"
  26 + (* | Sub -> LCGtypes.Atom "sub"
  27 + | Coord -> LCGtypes.Atom "coord" *)
  28 + | CompTypeUndef -> Top
  29 + (* | CompTypeAgr -> LCGtypes.AVar "ctype" *)
  30 +
  31 +let render_number = function
  32 + Number n -> Atom n
  33 + | NumberUndef -> Top
  34 + | NumberAgr -> Top
  35 +
  36 +let render_negation = function
  37 + Negation -> Atom "neg"
  38 + | Aff -> Atom "aff"
  39 + | NegationUndef -> Top
  40 +
  41 +let render_pos_entry = function
  42 + "subst" -> [Atom "subst"; AVar "number"; AVar "case"; AVar "gender"; AVar "person"]
  43 + | "ppron12" -> [Atom "ppron12"; AVar "number"; AVar "case"; AVar "gender"; AVar "person"]
  44 + | "ppron3" -> [Atom "ppron3"; AVar "number"; AVar "case"; AVar "gender"; AVar "person"]
  45 + | "siebie" -> [Atom "siebie"; AVar "case"]
  46 + | "num" -> [Atom "num"; AVar "number"; AVar "case"; AVar "gender"; AVar "person"]
  47 + | "intnum" -> [Atom "num"; AVar "number"; AVar "case"; AVar "gender"; AVar "person"]
  48 + | "prep" -> [Atom "prep"; AVar "case"]
  49 + | "adj" -> [Atom "adj"; AVar "number"; AVar "case"; AVar "gender"; AVar "grad"]
  50 + | "adv" -> [Atom "adv"; AVar "grad"]
  51 + | "ger" -> [Atom "ger"; AVar "number"; AVar "case"; AVar "gender"; AVar "person"; AVar "negation"]
  52 + | "pact" -> [Atom "pact"; AVar "number"; AVar "case"; AVar "gender"; AVar "negation"]
  53 + | "ppas" -> [Atom "ppas"; AVar "number"; AVar "case"; AVar "gender"; AVar "negation"]
  54 + | "inf" -> [Atom "inf"; AVar "aspect"; AVar "negation"]
  55 + | "qub" -> [Atom "qub"]
  56 + | "compar" -> [Atom "compar"; AVar "case"]
  57 + | "comp" -> [Atom "comp"; AVar "ctype"]
  58 + | "fin" -> [Atom "pers"; AVar "negation"]
  59 + | "praet" -> [Atom "pers"; AVar "negation"]
  60 + | "pred" -> [Atom "pers"; AVar "negation"]
  61 + | "winien" -> [Atom "pers"; AVar "negation"]
  62 + | "bedzie" -> [Atom "pers"; AVar "negation"]
  63 + | s -> print_endline ("render_pos_entry: " ^ s); []
  64 +
  65 +let render_pos = function (* wprowadzam uzgodnienia a nie wartości cech, bo wartości cech są wprowadzane przez leksem a uzgodnienia wiążą je z wartościami u nadrzędnika *)
  66 + | SUBST(number,Case case) -> [Atom "subst"; render_number number; Atom case; Top; Top]
  67 + | SUBST(_,NomAgr) -> [Atom "subst"; AVar "number"; Atom "nom"; AVar "gender"; AVar "person"]
  68 + | SUBST(_,GenAgr) -> [Atom "subst"; AVar "number"; Atom "gen"; AVar "gender"; AVar "person"]
  69 + | SUBST(_,AllAgr) -> [Atom "subst"; AVar "number"; AVar "case"; AVar "gender"; AVar "person"]
  70 + | SUBST(number,CaseAgr) -> [Atom "subst"; render_number number; AVar "case"; Top; Top]
  71 + | SUBST(_,CaseUndef) -> [Atom "subst"; Top; Top; Top; Top]
  72 + | PPRON12(number,Case case) -> [Atom "ppron12"; render_number number; Atom case; Top; Top]
  73 + | PPRON3(number,Case case) -> [Atom "ppron3"; render_number number; Atom case; Top; Top]
  74 + | SIEBIE(Case case) -> [Atom "siebie"; Atom case]
  75 + | NUM(Case case,_) -> [Atom "num"; Top; Atom case; Top; Top]
  76 + | NUM(NomAgr,_) -> [Atom "num"; AVar "number"; Atom "nom"; AVar "gender"; AVar "person"]
  77 +(* | NUM(CaseAgr,_) -> [Atom "num"; Top; AVar "case"; Top; Top]
  78 + | NUM(CaseUndef,_) -> [Atom "num"; Top; Top; Top; Top]*)
  79 + | PREP(Case case) -> [Atom "prep"; Atom case]
  80 + | ADJ(_,Case case,_,Grad grad) -> [Atom "adj"; Top; Atom case; Top; Atom grad]
  81 +(* | ADJ(_,NomAgr,_,_) -> [Atom "adj"; AVar "number"; Atom "nom"; AVar "gender"]
  82 + | ADJ(_,CaseAgr,_,_) -> [Atom "adj"; Top; AVar "case"; Top]*)
  83 + | ADJ(_,CaseUndef,_,Grad grad) -> [Atom "adj"; Top; Top; Top; Atom grad]
  84 + | ADJ(_,AllAgr,_,Grad grad) -> [Atom "adj"; AVar "number"; AVar "case"; AVar "gender"; Atom grad]
  85 + | ADJ(_,AllAgr,_,GradUndef) -> [Atom "adj"; AVar "number"; AVar "case"; AVar "gender"; Top]
  86 + | ADV (Grad grad) -> [Atom "adv"; Atom grad]
  87 + | ADV GradUndef -> [Atom "adv"; Top]
  88 + | GER(_,Case case,_,_,neg) -> [Atom "ger"; Top; Atom case; Top; Top; render_negation neg]
  89 +(* | GER(_,NomAgr,_,_,_) -> [Atom "ger"; AVar "number"; Atom "nom"; AVar "gender"; AVar "person"]
  90 + | GER(_,CaseAgr,_,_,_) -> [Atom "ger"; Top; AVar "case"; Top; Top]
  91 + | GER(_,CaseUndef,_,_,_) -> [Atom "ger"; Top; Top; Top; Top]
  92 + | PACT(_,Case case,_,_,_) -> [Atom "pact"; Top; Atom case; Top]
  93 + | PACT(_,NomAgr,_,_,_) -> [Atom "pact"; AVar "number"; Atom "nom"; AVar "gender"]*)
  94 + | PACT(_,AllAgr,_,_,neg) -> [Atom "pact"; AVar "number"; AVar "case"; AVar "gender"; render_negation neg]
  95 +(* | PACT(_,CaseAgr,_,_,_) -> [Atom "pact"; Top; AVar "case"; Top]*)
  96 + | PPAS(_,Case case,_,_,neg) -> [Atom "ppas"; Top; Atom case; Top; render_negation neg]
  97 + | PPAS(_,CaseUndef,_,_,neg) -> [Atom "ppas"; Top; Top; Top; render_negation neg]
  98 + (* | PPAS(_,NomAgr,_,_,_) -> [Atom "ppas"; AVar "number"; Atom "nom"; AVar "gender"]*)
  99 + | PPAS(_,AllAgr,_,_,neg) -> [Atom "ppas"; AVar "number"; AVar "case"; AVar "gender"; render_negation neg]
  100 +(* | PPAS(_,CaseAgr,_,_,_) -> [Atom "ppas"; Top; AVar "case"; Top]*)
  101 + | INF(Aspect aspect,neg) -> [Atom "inf"; Atom aspect; render_negation neg]
  102 + | INF(AspectUndef,neg) -> [Atom "inf"; Top; render_negation neg]
  103 + | QUB -> [Atom "qub"]
  104 + | COMPAR (Case case) -> [Atom "compar"; Atom case]
  105 + | COMP ctype -> [Atom "comp"; arg_of_ctype ctype]
  106 + | PERS neg -> [Atom "pers"; render_negation neg]
  107 + | pos -> print_endline ("render_pos: " ^ ENIAMwalStringOf.pos pos); []
  108 +
  109 +let render_phrase = function
  110 + NP(Case case) -> Tensor[Atom "np"; Top; Atom case; Top; Top]
  111 + | NP NomAgr -> Tensor[Atom "np"; AVar "number"; Atom "nom"; AVar "gender"; AVar "person"]
  112 +(* | NP GenAgr -> Tensor[Atom "np"; AVar "number"; Atom "gen"; AVar "gender"; AVar "person"]
  113 + | NP AllAgr -> Tensor[Atom "np"; AVar "number"; AVar "case"; AVar "gender"; AVar "person"]*)
  114 + | NP CaseAgr -> Tensor[Atom "np"; Top; AVar "case"; Top; Top]
  115 +(* | NP CaseUndef -> Tensor[Atom "np"; Top; Top; Top; Top]
  116 + | PrepNP("",CaseUndef) -> Tensor[Atom "prepnp"; Top; Top]*)
  117 + | PrepNP(prep,Case case) -> Tensor[Atom "prepnp"; Atom prep; Atom case]
  118 + | AdjP(Case case) -> Tensor[Atom "adjp"; Top; Atom case; Top]
  119 +(* | AdjP NomAgr -> Tensor[Atom "adjp"; AVar "number"; Atom "nom"; AVar "gender"]*)
  120 + | AdjP AllAgr -> Tensor[Atom "adjp"; AVar "number"; AVar "case"; AVar "gender"]
  121 +(* | AdjP CaseAgr -> Tensor[Atom "adjp"; Top; AVar "case"; Top]
  122 + | PrepAdjP("",CaseUndef) -> Tensor[Atom "prepnp"; Top; Top]*)
  123 + | PrepAdjP(prep,Case case) -> Tensor[Atom "prepadjp"; Atom prep; Atom case]
  124 + (* | NumP(Case case) -> Tensor[Atom "nump"; Top; Atom case; Top; Top]
  125 + | NumP NomAgr -> Tensor[Atom "nump"; AVar "number"; Atom "nom"; AVar "gender"; AVar "person"]
  126 + | NumP CaseAgr -> Tensor[Atom "nump"; Top; AVar "case"; Top; Top]
  127 + | NumP CaseUndef -> Tensor[Atom "nump"; Top; Top; Top; Top]
  128 + | PrepNumP(_,"",CaseUndef) -> Tensor[Atom "prepnp"; Top; Top]
  129 + | PrepNumP(_,prep,Case case) -> Tensor[Atom "prepnump"; Atom prep; Atom case] *)
  130 +(* | ComprepNP("") -> Tensor[Atom "comprepnp"; Top]*)
  131 + | ComprepNP(prep) -> Tensor[Atom "comprepnp"; Atom prep]
  132 + | ComparP(prep,Case case) -> Tensor[Atom "comparnp"; Atom prep; Atom case]
  133 + (* | ComparPP(_,prep) -> Tensor[Atom "comparpp"; Atom prep] *)
  134 + (* | IP -> Tensor[Atom "ip";Top;Top;Top] *)
  135 + | CP (ctype,Comp comp) -> Tensor[Atom "cp"; arg_of_ctype ctype; Atom comp]
  136 + (* | CP (ctype,CompUndef) -> Tensor[Atom "cp"; arg_of_ctype ctype; Top]*)
  137 + | NCP(Case case,ctype,Comp comp) -> Tensor[Atom "ncp"; Top; Atom case; Top; Top; arg_of_ctype ctype; Atom comp]
  138 + (* | NCP(Case case,CompTypeUndef,CompUndef) -> Tensor[Atom "ncp"; Top; Atom case; Top; Top; Top; Top]*)
  139 + | NCP(NomAgr,ctype,Comp comp) -> Tensor[Atom "ncp"; AVar "number"; Atom "nom"; AVar "gender"; AVar "person"; arg_of_ctype ctype; Atom comp]
  140 + (* | NCP(NomAgr,CompTypeUndef,CompUndef) -> Tensor[Atom "ncp"; AVar "number"; Atom "nom"; AVar "gender"; AVar "person"; Top; Top]*)
  141 + | PrepNCP(prep,Case case,ctype,Comp comp) -> Tensor[Atom "prepncp"; Atom prep; Atom case; arg_of_ctype ctype; Atom comp]
  142 + | InfP(Aspect aspect) -> Tensor[Atom "infp"; Atom aspect]
  143 + | InfP AspectUndef -> Tensor[Atom "infp"; Top]
  144 + (* | PadvP -> Tensor[Atom "padvp"] *)
  145 + | AdvP -> Tensor[Atom "advp"]
  146 + | FixedP lex -> Tensor[Atom "fixed"; Atom lex]
  147 + (* | PrepP -> Tensor[Atom "prepp";Top]
  148 + | Prep("",CaseAgr) -> Tensor[Atom "prep"; Top; AVar "case"]
  149 + | Prep("",CaseUAgr) -> Tensor[Atom "prep"; Top; AVar "ucase"]
  150 + | Num(AllAgr,Acm acm) -> Tensor[Atom "num"; AVar "number"; AVar "case"; AVar "gender"; AVar "person"; Atom acm]
  151 + | Measure(AllUAgr) -> Tensor[Atom "measure"; AVar "unumber"; AVar "ucase"; AVar "ugender"; AVar "uperson"] *)
  152 + | Or -> Tensor[Atom "or"]
  153 + (* | Qub -> Tensor[Atom "qub"]*)
  154 + (* | Inclusion -> Tensor[Atom "inclusion"]
  155 + | Adja -> Tensor[Atom "adja"]
  156 + | Aglt -> Tensor[Atom "aglt"; AVar "number"; AVar "person"]
  157 + | AuxPast -> Tensor[Atom "aux-past"; AVar "number"; AVar "gender"; AVar "person"]
  158 + | AuxFut -> Tensor[Atom "aux-fut"; AVar "number"; AVar "gender"; AVar "person"]
  159 + | AuxImp -> Tensor[Atom "aux-imp"]
  160 + | Pro -> One
  161 + | ProNG -> One *)
  162 + | E Or -> Tensor[Atom "or"]
  163 + | E (CP(CompTypeUndef,CompUndef)) -> Tensor[Atom "cp"; Top; Top]
  164 + | E (NCP(NomAgr,CompTypeUndef,CompUndef)) -> Tensor[Atom "ncp"; AVar "number"; Atom "nom"; AVar "gender"; AVar "person"; Top; Top]
  165 + | E (NP(NomAgr)) -> Tensor[Atom "np"; AVar "number"; Atom "nom"; AVar "gender"; AVar "person"]
  166 + | E (PrepNP(prep,Case case)) -> Tensor[Atom "prepnp"; Atom prep; Atom case]
  167 + | E (NP(Case case)) -> Tensor[Atom "np"; Top; Atom case; Top; Top]
  168 + | E (NCP(Case case,CompTypeUndef,CompUndef)) -> Tensor[Atom "ncp"; Top; Atom case; Top; Top; Top; Top]
  169 + | E (PrepNCP(prep,Case case,CompTypeUndef,CompUndef)) -> Tensor[Atom "prepncp"; Atom prep; Atom case; Top; Top]
  170 + | phrase -> print_endline ("render_phrase: " ^ ENIAMwalStringOf.phrase phrase); Tensor []
  171 +
  172 +let render_morf = function
  173 + | Null -> One
  174 + (* | X -> Tensor[Atom "X"]
  175 + | Lex lex -> Tensor[Atom lex] *)
  176 + | LexArg(id,lex,pos) -> Tensor([Atom "lex";Atom (string_of_int id);Atom lex] @ render_pos pos)
  177 + | SimpleLexArg(lex,pos) -> Tensor([Atom "lex";Atom lex] @ render_pos pos)
  178 + | phrase -> render_phrase phrase
  179 +
  180 +let render_schema schema =
  181 + Xlist.map schema (fun p ->
  182 + Both,Plus(Xlist.map p.morfs render_morf))
  183 +
  184 +(* FIXME: tu trzeba by dodać zwykłe reguły dla czasowników dotyczące ich negacji, aglutynatu itp. *)
  185 +let render_lex_entry = function
  186 + SimpleLexEntry(lemma,pos) -> [Tensor([Atom "lex";Atom lemma] @ render_pos_entry pos)]
  187 + | LexEntry(id,lemma,pos,NoRestr,schema) ->
  188 + [ImpSet(Tensor([Atom "lex";Atom (string_of_int id);Atom lemma] @ render_pos_entry pos),render_schema schema)]
  189 + (*Xlist.map (transform_entry pos lemma NegationUndef PredFalse AspectUndef schema) (fun (sel,schema) ->
  190 + sel,LexEntry(id,lemma,pos,NoRestr,schema))*)
  191 + | ComprepNPEntry(prep,NoRestr,schema) -> [ImpSet(Tensor[Atom "comprepnp"; Atom prep],render_schema schema)]
  192 + (*Xlist.map (transform_entry "comprep" s NegationUndef PredFalse AspectUndef schema) (fun (sel,schema) ->
  193 + sel,ComprepNPEntry(s,NoRestr,schema))*)
  194 + | LexEntry(id,lemma,pos,_,[]) (*as entry*) ->
  195 + [ImpSet(Tensor([Atom "lex";Atom (string_of_int id);Atom lemma] @ render_pos_entry pos),[Both,Tensor[AVar "schema"]])]
  196 + | entry -> print_endline ("render_entry:" ^ ENIAMwalStringOf.lex_entry entry); [(*[],entry*)]
  197 +
  198 +let schemata,entries = ENIAMvalence.prepare_all_valence ENIAMwalParser.phrases ENIAMwalParser.schemata ENIAMwalParser.entries
  199 +
  200 +let _ =
  201 + (* Entries.map schemata (fun pos lemma (selectors,schema) ->
  202 + (* Printf.printf "%s %s %s\n" pos lemma (ENIAMwalStringOf.schema schema); *)
  203 + render_schema schema) *)
  204 + Entries.map entries (fun pos lemma (selectors,entry) ->
  205 + (* Printf.printf "%s %s %s\n" pos lemma (ENIAMwalStringOf.schema schema); *)
  206 + selectors,render_lex_entry entry)
... ...
lexSemantics/makefile
... ... @@ -28,8 +28,8 @@ eniam-lexSemantics.cmxa: $(SOURCES)
28 28  
29 29 # test: test.ml
30 30 # $(OCAMLOPT) -o test $(OCAMLOPTFLAGS) test.ml
31   -test: entries.ml ENIAMwalTypes.ml ENIAMwalStringOf.ml ENIAMwalParser.ml ENIAMwalReduce.ml ENIAMvalence.ml test.ml
32   - $(OCAMLOPT) -o test $(OCAMLOPTFLAGS) entries.ml ENIAMwalTypes.ml ENIAMwalStringOf.ml ENIAMwalParser.ml ENIAMwalReduce.ml ENIAMvalence.ml test.ml
  31 +test: entries.ml ENIAMwalTypes.ml ENIAMwalStringOf.ml ENIAMwalParser.ml ENIAMwalReduce.ml ENIAMvalence.ml ENIAMvalence2.ml test.ml
  32 + $(OCAMLOPT) -o test $(OCAMLOPTFLAGS) entries.ml ENIAMwalTypes.ml ENIAMwalStringOf.ml ENIAMwalParser.ml ENIAMwalReduce.ml ENIAMvalence.ml ENIAMvalence2.ml test.ml
33 33  
34 34  
35 35 .SUFFIXES: .mll .mly .ml .mli .cmo .cmi .cmx
... ...