//=============== Only PoS-Tagger (without Morphology) ===============// private static void ProcessText_without_Morphology(string text) { var(config, ssc) = PosTaggerEnvironment.CreatePosTaggerProcessorConfig(); using (ssc) using (var tokenizer = new Tokenizer(config.TokenizerConfig)) using (var posTaggerScriber = PosTaggerScriber.Create(config.ModelFilename, config.TemplateFilename)) { var posTaggerPreMerging = new PosTaggerPreMerging(config.Model); var result = new List <word_t>(); tokenizer.Run(text, true, words => { //-merge-phrases-abbreviations-numbers- posTaggerPreMerging.Run(words); //directly pos-tagging posTaggerScriber.Run(words); result.AddRange(words); }); Console.WriteLine("pos-tagger-entity-count: " + result.Count + Environment.NewLine); foreach (var w in result) { Console.WriteLine(w); } Console.WriteLine(); } }
private static async Task ProcessText(string text) { using (var posTagger = await PosTaggerEnvironment.CreateAsync().CAX()) { Console.WriteLine("\r\n-------------------------------------------------\r\n text: '" + text + '\''); var result = posTagger.Processor.Run(text, true); Console.WriteLine("-------------------------------------------------\r\n pos-tagger-entity-count: " + result.Count + Environment.NewLine); foreach (var word in result) { Console.WriteLine(word); } Console.WriteLine(); var result_details = posTagger.Processor.Run_Details(text, true, true, true, true); Console.WriteLine("-------------------------------------------------\r\n pos-tagger-entity-count: " + result_details.Count + Environment.NewLine); foreach (var r in result_details) { foreach (var word in r) { Console.WriteLine(word); } Console.WriteLine(); } Console.WriteLine("-------------------------------------------------\r\n"); } }
public static async Task <PosTaggerEnvironment> CreateAsync() { var sw = Stopwatch.StartNew(); var morphoModelConfig = CreateMorphoModelConfig(); var morphoAmbiguityModel_task = Task.Run(() => CreateMorphoAmbiguityResolverModel()); var morphoModel_task = Task.Run(() => MorphoModelFactory.Create(morphoModelConfig)); var config_task = Task.Run(() => CreatePosTaggerProcessorConfig()); await Task.WhenAll(morphoAmbiguityModel_task, morphoModel_task, config_task).CAX(); var morphoAmbiguityModel = morphoAmbiguityModel_task.Result; var morphoModel = morphoModel_task.Result; var(config, ssc) = config_task.Result; var posTaggerProcessor = new PosTaggerProcessor(config, morphoModel, morphoAmbiguityModel); var posEnv = new PosTaggerEnvironment() { MorphoAmbiguityResolverModel = morphoAmbiguityModel, MorphoModel = morphoModel, SentSplitterConfig = ssc, Processor = posTaggerProcessor, }; sw.Stop(); Console.WriteLine($"load models elapsed: {sw.Elapsed}"); return(posEnv); }
private static void ProcessText(string text) { using (var posTagger = PosTaggerEnvironment.Create()) { Console.WriteLine("\r\n-------------------------------------------------\r\n text: '" + text + '\''); var result = posTagger.Processor.Run(text, true); Console.WriteLine("-------------------------------------------------\r\n pos-tagger-entity-count: " + result.Count + Environment.NewLine); foreach (var word in result) { Console.WriteLine(word); } Console.WriteLine(); var result_debug = posTagger.Processor.Run_Debug(text, true, true, true, true); Console.WriteLine("-------------------------------------------------\r\n pos-tagger-entity-count: " + result_debug.Count + Environment.NewLine); foreach (var r in result_debug) { foreach (var word in r) { Console.WriteLine(word); } Console.WriteLine(); } Console.WriteLine("-------------------------------------------------\r\n"); } }
public static PosTaggerEnvironment Create() { var morphoAmbiguityModel = CreateMorphoAmbiguityResolverModel(); var morphoModelConfig = CreateMorphoModelConfig(); var morphoModel = MorphoModelFactory.Create(morphoModelConfig); var config = CreatePosTaggerProcessorConfig(); var posTaggerProcessor = new PosTaggerProcessor(config, morphoModel, morphoAmbiguityModel); var x = new PosTaggerEnvironment() { MorphoAmbiguityResolverModel = morphoAmbiguityModel, MorphoModel = morphoModel, Processor = posTaggerProcessor, }; return(x); }
public static PosTaggerEnvironment Create() { var sw = Stopwatch.StartNew(); var morphoAmbiguityModel = CreateMorphoAmbiguityResolverModel(); var morphoModelConfig = CreateMorphoModelConfig(); var morphoModel = MorphoModelFactory.Create(morphoModelConfig); var(config, ssc) = CreatePosTaggerProcessorConfig(); var posTaggerProcessor = new PosTaggerProcessor(config, morphoModel, morphoAmbiguityModel); var posEnv = new PosTaggerEnvironment() { MorphoAmbiguityResolverModel = morphoAmbiguityModel, MorphoModel = morphoModel, SentSplitterConfig = ssc, Processor = posTaggerProcessor, }; sw.Stop(); Console.WriteLine($"load models elapsed: {sw.Elapsed}"); return(posEnv); }