static void Main(string[] args) { Options options; Notenizer notenizer; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); options = new Options(); if (CommandLine.Parser.Default.ParseArguments(args, options)) { if (options.User != String.Empty && options.Password == String.Empty || options.User == String.Empty && options.Password != String.Empty) { Console.WriteLine("User or password missing."); return; } ConnectionManager.HostName = options.Host; ConnectionManager.Password = options.Password; ConnectionManager.Port = options.Port; ConnectionManager.UserName = options.User; notenizer = new Notenizer(options.Verbose); if (options.DatabaseName != null) ConnectionManager.DatabaseName = options.DatabaseName; var c = ConnectionManager.Client; if (options.RunAnalysis) Analyzator.Analyze(); else if (!options.IsConsole) { if (options.Text != String.Empty) Application.Run(new FormMain(options.Text, options.Verbose)); else if (options.Url != String.Empty) Application.Run(new FormMain(WikiParser.Parse(options.Url), options.Verbose)); else if (options.Country != String.Empty) Application.Run(new FormMain(WikiParser.ParseCountry(options.Country), options.Verbose)); else Application.Run(new FormMain(options.Verbose)); } else if (options.IsConsole) { if (options.Text != String.Empty) notenizer.RunCoreNLP(options.Text); else if (options.Url != String.Empty) notenizer.RunCoreNLP(WikiParser.Parse(options.Url)); else if (options.Country != String.Empty) notenizer.RunCoreNLP(WikiParser.ParseCountry(options.Country)); } } }
public static void Analyze() { long notesCount; long rulesCount; long articlesCount; long andRulesCount; long sentencesCount; long structuresCount; StanfordCoreNLP pipe; Annotation annotation; long articlesSentencesCount; List<BsonDocument> articles; pipe = new Notenizer(true).Pipeline; notesCount = GetCount(DBConstants.NotesCollectionName); rulesCount = GetCount(DBConstants.RulesCollectionName); andRulesCount = GetCount(DBConstants.AndRulesCollectionName); sentencesCount = GetCount(DBConstants.SentencesCollectionName); structuresCount = GetCount(DBConstants.StructuresCollectionName); articles = GetAll(DBConstants.ArticlesCollectionName); articlesCount = articles.Count; articlesSentencesCount = 0; Console.WriteLine(String.Format("Getting number of sentences in {0} articles...", articlesCount)); for (int i = 0; i < articlesCount; i++) { Console.Write(String.Format("Parsing article no.{0} ... ", i + 1)); annotation = new Annotation(articles[i][DBConstants.TextFieldName].AsString); pipe.annotate(annotation); articlesSentencesCount += (annotation.get(typeof(CoreAnnotations.SentencesAnnotation)) as java.util.ArrayList).size(); Console.WriteLine("Done."); } Console.WriteLine(String.Format("{0}{0}Analysis:", Environment.NewLine)); Notify(DBConstants.NotesCollectionName, notesCount); Notify(DBConstants.SentencesCollectionName, sentencesCount); Notify(DBConstants.RulesCollectionName, rulesCount); Notify(DBConstants.AndRulesCollectionName, andRulesCount); Notify(DBConstants.StructuresCollectionName, structuresCount); Notify(DBConstants.ArticlesCollectionName, articlesCount); Console.WriteLine(String.Format("Number of sentences in articles: {0}", articlesSentencesCount)); }