/// <summary> /// Gets all synonyms of the given word in the given part of speech and finds the most complex word in the set. /// Uses WordNet as thesaurus and weighted scores to determine which is most complex. /// </summary> /// <param name="word">Word to get synonyms of.</param> /// <param name="pos">Part of speech of the given word. Used to find more accurate synonyms.</param> /// <returns>The most complex synonym of the given word in the given part of speech.</returns> public static string GetMostComplexSynyonymScoredWN(string word, Wnlib.PartsOfSpeech pos) { // TODO: Lemmatization? if (pos == Wnlib.PartsOfSpeech.Unknown) { // We're gonna have some serious problems (namely, a NullReferenceException) if we don't back out of this right now. return(word); } string[] synonymsArr = Lexicon.FindSynonyms(word, pos, false); if (synonymsArr == null || synonymsArr.Length == 0) { return(word); } List <string> synonyms = new List <string>(synonymsArr); string mostComplexSynyonym = ""; double mostComplexScore = 0.0; #region Synonym collection setup if (!synonyms.Contains <string>(word)) { synonyms.Add(word); } #endregion #region Most complex synonym find foreach (string cs in synonyms) { double csScore = WordRater.GetTotalScore(cs); if (mostComplexSynyonym == "" || csScore > mostComplexScore) { mostComplexSynyonym = cs; mostComplexScore = csScore; } } #endregion return(mostComplexSynyonym); }
///////////////////////////////////////////////////////////////////////////////////// public HomeController(IOptions <TwitterCrawlerConfig> config) { posTagger = new PosTagger(); twitterCrawler = new TwitterCrawler(config); tokenizer = new Tokenizer(); tokenAnalyser = new TokenAnalyser(); tweetAnalyser = new TweetAnalyser(); wordRater = new WordRater(); sentimentCalculator = new SentimentCalculator(); preprocessor = new Preprocessor(); parseTreeAnalyser = new ParseTreeAnalyser(); networkSendClientSocket = new NetworkClientSocket(NetworkSendClientPort, NetworkClientHost); networkReceiveClientSocket = new NetworkClientSocket(NetworkReceiveClientPort, NetworkClientHost); serializer = new Serializer(); deserializer = new Deserializer(); tester = new Tester(); }