Esempio n. 1
0
        /// <summary>
        /// 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.
        /// In addition, this method returns additional partial matches in the 'out' parameter where one
        /// of the search keys matches the beginning of one of the words in the domain's Name or Example
        /// Words fields.
        ///
        /// N.B.: This method looks for matches in the AnalysisDefaultWritingSystem.
        /// This ought to help ensure that we are searching in the Semantic Domain fields in the same
        /// writing system as the one the search keys in the Sense came from.
        /// </summary>
        /// <param name="sense">A LexSense</param>
        /// <param name="partialMatches">extra partial matches</param>
        /// <returns></returns>
        public IEnumerable <ICmSemanticDomain> FindDomainsThatMatchWordsIn(ILexSense sense,
                                                                           out IEnumerable <ICmSemanticDomain> partialMatches)
        {
            var strategy = new SenseSearchStrategy(Cache, sense);

            new SemDomSearchEngine(Cache).WalkDomains(strategy);

            partialMatches = strategy.PartialMatches;

            return(strategy.FindResults);
        }
        /// <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);
        }