ENIAMmstFeatures.ml 1.14 KB
open ENIAMmstModel
open ENIAM_LCGtypes

type disamb_info = {
  tree: node array
}

let apply_features features fv =
  List.fold_left (|>) fv features

let add_linear_features f_type (obs: string array) first second distStr fv =
  fv

let add_two_obs_features prefix item1F1 item1F2 item2F1 item2F2 distStr fv =
  let add_diststr str = [str; str^"*"^distStr] in
  let flist = List.map ((^) prefix)[
      "2FF1="^item1F1;
      "2FF1="^item1F1^" "^item1F2;
      "2FF1="^item1F1^" "^item1F2^" "^item2F2;
      "2FF1="^item1F1^" "^item1F2^" "^item2F2^" "^item2F1;
      "2FF2="^item1F1^" "^item2F1;
      "2FF3="^item1F1^" "^item2F2;
      "2FF4="^item1F2^" "^item2F1^" "^item2F2;
      "2FF5="^item1F2^" "^item2F2;
      "2FF6="^item2F1^" "^item2F2;
      "2FF7="^item1F2;
      "2FF8="^item2F1;
      "2FF9="^item2F2;
    ] in
  let funs = List.map (MST_Model.add_feature) (List.flatten (List.map add_diststr flist)) in
  apply_features funs fv

let score_edge (data: disamb_info) (parent: node) (child: node) =
  let fv = MST_Model.empty_fv in
  let fv = add_two_obs_features "HC"
      parent.orth parent.pos child.orth child.pos "" fv in
  MST_Model.score_fv fv