public RelatedWords GetRelatedWords(string word)
        {
            var words = new RelatedWords();

            words.Means      = (GetResults($"http://api.datamuse.com/words?ml={word}")).OrderByDescending(each => each.Score).ToList();
            words.Synonyms   = (GetResults($"http://api.datamuse.com/words?rel_syn={word}")).OrderByDescending(each => each.Score).ToList();
            words.Kinds      = (GetResults($"http://api.datamuse.com/words?rel_spc={word}")).OrderByDescending(each => each.Score).ToList();
            words.Comprises  = (GetResults($"http://api.datamuse.com/words?rel_com={word}")).OrderByDescending(each => each.Score).ToList();
            words.Homophones = (GetResults($"http://api.datamuse.com/words?rel_hom={word}")).OrderByDescending(each => each.Score).ToList();
            words.Consonants = (GetResults($"http://api.datamuse.com/words?rel_cns={word}")).OrderByDescending(each => each.Score).ToList();
            words.Rhymes     = GetRhymes(word);

            return(words);
        }
Exemple #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Assuming the selection can be expanded to a word and a corresponding LexEntry can
		/// be found, show the related words dialog with the words related to the selected one.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="sel">The sel.</param>
		/// <param name="owner">The owner.</param>
		/// <param name="mediatorIn"></param>
		/// <param name="helpProvider"></param>
		/// <param name="helpFileKey"></param>
		/// ------------------------------------------------------------------------------------
		public static void DisplayRelatedEntries(FdoCache cache, IVwSelection sel, IWin32Window owner,
			Mediator mediatorIn, IHelpTopicProvider helpProvider, string helpFileKey)
		{
			if (sel == null)
				return;
			IVwSelection sel2 = sel.EndPoint(false);
			if (sel2 == null)
				return;
			IVwSelection sel3 = sel2.GrowToWord();
			if (sel3 == null)
				return;
			ITsString tss;
			int ichMin, ichLim, hvo, tag, ws;
			bool fAssocPrev;
			sel3.TextSelInfo(false, out tss, out ichMin, out fAssocPrev, out hvo, out tag, out ws);
			sel3.TextSelInfo(true, out tss, out ichLim, out fAssocPrev, out hvo, out tag, out ws);
			if (tss.Text == null)
				return;
			ITsString tssWf = tss.GetSubstring(ichMin, ichLim);
			using (LexEntryUi leui = FindEntryForWordform(cache, tssWf))
			{
				// This doesn't work as well (unless we do a commit) because it may not see current typing.
				//LexEntryUi leui = LexEntryUi.FindEntryForWordform(cache, hvo, tag, ichMin, ichLim);
				if (leui == null)
				{
					if (tssWf != null && tssWf.Length > 0)
						RelatedWords.ShowNotInDictMessage(owner);
					return;
				}
				int hvoEntry = leui.Object.Hvo;
				int[] domains;
				int[] lexrels;
				IVwCacheDa cdaTemp;
				if (!RelatedWords.LoadDomainAndRelationInfo(cache, hvoEntry, out domains, out lexrels, out cdaTemp, owner))
					return;
				StringTable stOrig;
				Mediator mediator;
				IVwStylesheet styleSheet;
				bool fRestore = EnsureFlexTypeSetup(cache, mediatorIn, out stOrig, out mediator, out styleSheet);
				using (RelatedWords rw = new RelatedWords(cache, sel3, hvoEntry, domains, lexrels, cdaTemp, styleSheet, mediatorIn, false))
				{
					rw.ShowDialog(owner);
				}
				if (fRestore)
					mediator.StringTbl = stOrig;
			}
		}
Exemple #3
0
		/// ------------------------------------------------------------
		/// <summary>
		/// Assuming the selection can be expanded to a word and a corresponding LexEntry can
		/// be found, show the related words dialog with the words related to the selected one.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="owner">The owning window.</param>
		/// <param name="mediatorIn">The mediator.</param>
		/// <param name="helpProvider">The help provider.</param>
		/// <param name="helpFileKey">The help file key.</param>
		/// <param name="tssWf">The ITsString for the word form.</param>
		/// <param name="hideInsertButton"></param>
		/// ------------------------------------------------------------
		// Currently only called from WCF (11/21/2013 - AP)
		public static void DisplayRelatedEntries(FdoCache cache, IWin32Window owner,
			Mediator mediatorIn, IHelpTopicProvider helpProvider, string helpFileKey, ITsString tssWf,
			bool hideInsertButton)
		{
			if (tssWf == null || tssWf.Length == 0)
				return;

			using (LexEntryUi leui = FindEntryForWordform(cache, tssWf))
			{
				// This doesn't work as well (unless we do a commit) because it may not see current typing.
				//LexEntryUi leui = LexEntryUi.FindEntryForWordform(cache, hvo, tag, ichMin, ichLim);
				if (leui == null)
				{
					RelatedWords.ShowNotInDictMessage(owner);
					return;
				}
				int hvoEntry = leui.Object.Hvo;
				int[] domains;
				int[] lexrels;
				IVwCacheDa cdaTemp;
				if (!RelatedWords.LoadDomainAndRelationInfo(cache, hvoEntry, out domains, out lexrels, out cdaTemp, owner))
					return;
				StringTable stOrig;
				Mediator mediator;
				IVwStylesheet styleSheet;
				bool fRestore = EnsureFlexTypeSetup(cache, mediatorIn, out stOrig, out mediator, out styleSheet);
				using (RelatedWords rw = new RelatedWords(cache, null, hvoEntry, domains, lexrels, cdaTemp, styleSheet,
					mediatorIn, hideInsertButton))
				{
					rw.ShowDialog(owner);
				}
				if (fRestore)
					mediator.StringTbl = stOrig;
			}
		}