public SentimentAnalyzeResult Analyze() { var model = Train(); var category = new DocumentCategorizerME(model); var evaluator = new DocumentCategorizerEvaluator(category); //var expectedDocumentCategory = "Movies"; var content = GetSourceText(); var sample = new DocumentSample("Call", content); var distribution = category.Categorize(content); var predictedCategory = category.GetBestCategory(distribution); using (var stream = new FileStream(Path.Combine(AppConfig.GetAppBasePath(), "en-sentiment.bin"), FileMode.Append)) SerializeHelper.Serialize(stream, model); return(predictedCategory.ConvertRawResultAsSentimentResult()); }
public override void run(string[] args) { if (0 == args.Length) { Console.WriteLine(Help); } else { DoccatModel model = (new DoccatModelLoader()).load(new File(args[0])); DocumentCategorizerME doccat = new DocumentCategorizerME(model); ObjectStream <string> documentStream = new ParagraphStream(new PlainTextByLineStream(new InputStreamReader(Console.OpenStandardInput))); PerformanceMonitor perfMon = new PerformanceMonitor(System.err, "doc"); perfMon.start(); try { string document; while ((document = documentStream.read()) != null) { double[] prob = doccat.categorize(WhitespaceTokenizer.INSTANCE.tokenize(document)); string category = doccat.getBestCategory(prob); DocumentSample sample = new DocumentSample(category, document); Console.WriteLine(sample.ToString()); perfMon.incrementCounter(); } } catch (IOException e) { CmdLineUtil.handleStdinIoError(e); } perfMon.stopAndPrintFinalResult(); } }
private static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); //Paragraphs ParagraphSample.SimpleFormattedParagraphs(); ParagraphSample.ForceParagraphOnSinglePage(); ParagraphSample.ForceMultiParagraphsOnSinglePage(); ParagraphSample.TextActions(); ParagraphSample.Heading(); ////Document DocumentSample.AddCustomProperties(); DocumentSample.ReplaceText(); DocumentSample.ApplyTemplate(); DocumentSample.AppendDocument(); //Images ImageSample.AddPicture(); ImageSample.CopyPicture(); ImageSample.ModifyImage(); //Indentation/Direction/Margins MarginSample.SetDirection(); MarginSample.Indentation(); MarginSample.Margins(); //Header/Footers HeaderFooterSample.HeadersFooters(); //Tables TableSample.InsertRowAndImageTable(); TableSample.TextDirectionTable(); TableSample.CreateRowsFromTemplate(); TableSample.ColumnsWidth(); TableSample.MergeCells(); //Hyperlink HyperlinkSample.Hyperlinks(); //Section SectionSample.InsertSections(); //Lists ListSample.AddList(); //Equations EquationSample.InsertEquation(); //Bookmarks BookmarkSample.InsertBookmarks(); BookmarkSample.ReplaceText(); //Charts ChartSample.BarChart(); ChartSample.LineChart(); ChartSample.PieChart(); ChartSample.Chart3D(); //Tale of Content TableOfContentSample.InsertTableOfContent(); TableOfContentSample.InsertTableOfContentWithReference(); //Lines LineSample.InsertHorizontalLine(); //Protection ProtectionSample.AddPasswordProtection(); ProtectionSample.AddProtection(); //Parallel ParallelSample.DoParallelActions(); //Others MiscellaneousSample.CreateRecipe(); MiscellaneousSample.CompanyReport(); MiscellaneousSample.CreateInvoice(); Console.WriteLine("\nPress any key to exit."); Console.ReadKey(); }
public async Task <IActionResult> Create(DocumentSample documentSample, IFormFile uploadedFile) { await _documentSamplesRepository.AddDocumentSampleAsync(documentSample, uploadedFile); return(RedirectToAction(nameof(Index))); }