Commit baee9cd4 authored by Bruno Guillaume's avatar Bruno Guillaume

add Amr support

parent 0c5acfe6
S src
B _build/src
PKG yojson log svg conll dep2pict libgrew_dev lablgtk2 lablwebkit
PKG yojson log svg amr conll dep2pict libgrew_dev lablgtk2 lablwebkit
true: package(yojson, containers, str, ANSITerminal, camomile, cairo2, log, conll, dep2pict, lablgtk2, lablgtk2.rsvg, lablgtk2.glade, lablwebkit)
true: package(yojson, containers, str, ANSITerminal, camomile, cairo2, log, amr, conll, dep2pict, lablgtk2, lablgtk2.rsvg, lablgtk2.glade, lablwebkit)
true: bin_annot
\ No newline at end of file
......@@ -12,6 +12,7 @@ open Printf
open Log
open Conll
open Libgrew
open Libamr
open Dep2pict
......@@ -151,6 +152,16 @@ module Corpus = struct
let conll_corpus = Conll_corpus.load file in
Array.map (fun (sentid, conll) -> (sentid, Graph.of_conll ?domain conll)) conll_corpus
let load_amr ?domain file =
let amr_corpus = Amr_corpus.load file in
Array.map (fun (sent_id,text,amr) ->
try
let gr = Amr.to_gr amr in
let graph = Graph.of_gr ?domain gr in
(sent_id, graph)
with exc -> Log.fwarning "[id=%s] AMR skipped [exception: %s]" sent_id (Printexc.to_string exc); exit 1;
) amr_corpus
let load_brown ?domain file =
let lines = File.read file in
let brown_list =
......@@ -194,13 +205,15 @@ module Corpus = struct
| Some s when String_.contains "conll" s -> load_conll ?domain source
| Some s when String_.contains "melt" s -> load_brown ?domain source
| Some s when String_.contains "brown" s -> load_brown ?domain source
| Some s when String_.contains "amr" s -> load_amr ?domain source
| Some s when String_.contains "gr" s -> [| (source, Graph.load ?domain source) |]
| _ ->
Log.fwarning "Unknown suffix for file \"%s\", trying to guess format..." source;
try load_conll ?domain source
with _ ->
try load_brown ?domain source
with _ ->
try load_amr ?domain source
with _ -> raise (Fail (sprintf "Cannot load file \"%s\", unknown format" source))
end (* module Corpus *)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment