/// <exception cref="System.Exception"/> public static void Main(string[] args) { Properties props = StringUtils.ArgsToProperties(args); StanfordCoreNLP pipeline = new StanfordCoreNLP(props); string file = props.GetProperty("file"); string loadFile = props.GetProperty("loadFile"); if (loadFile != null && !loadFile.IsEmpty()) { Edu.Stanford.Nlp.Pipeline.CustomAnnotationSerializer ser = new Edu.Stanford.Nlp.Pipeline.CustomAnnotationSerializer(false, false); InputStream @is = new FileInputStream(loadFile); Pair <Annotation, InputStream> pair = ser.Read(@is); pair.second.Close(); Annotation anno = pair.first; System.Console.Out.WriteLine(anno.ToShorterString(StringUtils.EmptyStringArray)); @is.Close(); } else { if (file != null && !file.Equals(string.Empty)) { string text = IOUtils.SlurpFile(file); Annotation doc = new Annotation(text); pipeline.Annotate(doc); Edu.Stanford.Nlp.Pipeline.CustomAnnotationSerializer ser = new Edu.Stanford.Nlp.Pipeline.CustomAnnotationSerializer(false, false); TextWriter os = new TextWriter(new FileOutputStream(file + ".ser")); ser.Write(doc, os).Close(); log.Info("Serialized annotation saved in " + file + ".ser"); } else { log.Info("usage: CustomAnnotationSerializer [-file file] [-loadFile file]"); } } }