static void ProcessCommand(string command) { string[] blocks = command.Split(); switch (blocks[0].ToLower()) { case "": return; case "exit": if (blocks.Length == 1) _exitFlag = true; else Console.WriteLine("Unknown Parameters."); return; case "clear": if (blocks.Length == 1) Console.Clear(); else Console.WriteLine("Unknown Parameters."); return; case "genas": AnnotationDictionary dict = new AnnotationDictionary(); AnnotationSet ans = new AnnotationSet("WEMAS"); dict.Load("WEMAS.xml"); foreach (var entry in dict._Dictionary) { ans.SetAnnotationDescription(entry.Key, entry.Value); } foreach (var sep in dict.SentenceSeparators) { ans.AddSentenceSeparator(sep); } ans.Save("WEMAS.wemas"); return; case "testas": AnnotationSet ans2 = new AnnotationSet("WEMAS"); ans2.Load("WEMAS.wemas"); ans2.Description = "WEB ENTITY MINER Default Annotation Set."; ans2.Save("WEMAS2.wemas"); return; case "testws": AnnotationSet wemas = new AnnotationSet(); wemas.Load("WEMAS.wemas"); ICTCLASAnnotator ano = new ICTCLASAnnotator(wemas, null); CRFPPAnnotator crfAno = new CRFPPAnnotator(wemas, new Model( AppDomain.CurrentDomain.BaseDirectory + "model.crfppmodel")); Corpus c = new Corpus(Encoding.UTF8); SentenceFactory.AnnotationSet = wemas; SentenceFactory.InputLanguage = Language.SimplifiedChinese; SentenceFactory.OutputEncoding = Encoding.UTF8; var sens = SentenceFactory.GetSentences( new FileStream("utf8.txt", FileMode.Open, FileAccess.Read)); WEMDocument doc = new WEMDocument(Encoding.UTF8); foreach (var sen in sens) { doc.AddSentence(sen); } c.AddDocument(doc); try { ano.ProcessCorpus(c); crfAno.ProcessCorpus(c); } catch (Exception ex) { Console.WriteLine("Unhandled Exception:\n{0}", ex.Message); } doc.Save("RESULT.xml"); foreach (var sententce in doc.Sentences) { foreach (var word in sententce.Words) { if (word is Entity) { Console.WriteLine("{0}/ENTITY:{1}", word.Content, wemas[((Entity)word).EntityId]); } else { Console.WriteLine("{0}", word.Content); } } } return; default: Console.WriteLine("Unknown Command: '{0}'.", blocks[0]); return; } }