예제 #1
0
		public SemanticDomainChooserBEditControl(FdoCache cache, Mediator mediator, BulkEditBar bar, XmlNode colSpec) :
			base(cache, mediator, colSpec)
		{
			m_suggestButton = new Button();
			m_suggestButton.Text = XMLViewsStrings.ksSuggestButtonText;
			m_suggestButton.Image = ResourceHelper.SuggestLightbulb;
			m_suggestButton.ImageAlign = ContentAlignment.MiddleRight;
			m_toolTip = new ToolTip();
			m_toolTip.SetToolTip(m_suggestButton, XMLViewsStrings.ksSuggestButtonToolTip);
			m_doingSuggest = false;
			m_semDomRepo = cache.ServiceLocator.GetInstance<ICmSemanticDomainRepository>();
			m_bar = bar;
			m_searchCache = new SemDomSearchCache(cache);
		}
		/// <summary>
		/// This method assumes that a SemDomSearchCache has cached the Semantic Domains by
		/// search key (a Tuple of word string and writing system integer). It then takes the gloss,
		/// a short definition (if only one or two words), and reversal from a LexSense and uses those
		/// words as search keys to find Semantic Domains that have one of those words in
		/// their Name or Example Words fields.
		/// </summary>
		/// <param name="semDomCache"></param>
		/// <param name="sense"></param>
		/// <returns></returns>
		public IEnumerable<ICmSemanticDomain> FindCachedDomainsThatMatchWordsInSense(
			SemDomSearchCache semDomCache, ILexSense sense)
		{
			var strategy = new SenseSearchStrategy(Cache, sense);
			var results = new Set<ICmSemanticDomain>();
			foreach (var keyValuePair in strategy.GetSearchKeysFromSense())
			{
				foreach (var wordFromSense in keyValuePair.Value)
				{
					var cachedDomains = semDomCache.GetDomainsForCachedString(keyValuePair.Key, wordFromSense);
					if (cachedDomains == null)
						continue;
					results.AddRange(cachedDomains);
				}
			}
			return results;
		}