示例#1
0
        /// <summary>
        /// Queries the specified tokens.
        /// </summary>
        /// <param name="tokens">The tokens.</param>
        /// <param name="scope">The scope.</param>
        /// <param name="side">The side.</param>
        /// <returns></returns>
        public apertiumDictionaryResult query(IEnumerable <String> tokens, apertiumDictQueryScope scope = apertiumDictQueryScope.startingWith, apertiumDictNeedleSide side = apertiumDictNeedleSide.native)
        {
            apertiumDictionaryResult output    = new apertiumDictionaryResult();
            List <String>            queryList = new List <string>();

            foreach (String tkn in tokens)
            {
                if (!tkn.isNullOrEmpty())
                {
                    queryList.Add(makeQuery(tkn, scope, side));
                }
            }


            var res = dictionaryOperator.Search(queryList, true, RegexOptions.IgnoreCase);


            foreach (String line in res.getLines(true))
            {
                output.addLine(line);
            }


            return(output);
        }
        /// <summary>
        /// Queries for synonyms.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <param name="scope">The scope.</param>
        /// <returns></returns>
        public apertiumDictionaryResult queryForSynonyms(String token, apertiumDictQueryScope scope = apertiumDictQueryScope.startingWith)
        {
            apertiumDictionaryResult output    = new apertiumDictionaryResult();
            apertiumDictionaryResult firstStep = query(token, scope, apertiumDictNeedleSide.native);
            var engList = firstStep.GetTranslatedWords();

            output = query(engList, scope, apertiumDictNeedleSide.translated);
            return(output);
        }
        /// <summary>
        /// Queries the dictionary for translation of <c>token</c>, into opposite <c>side</c>
        /// </summary>
        /// <param name="token">The token to translate, in language of the <c>side</c> specified</param>
        /// <param name="scope">The scope of search, the matching rule</param>
        /// <param name="side">Side of the dictionary that the search <c>token</c> is from</param>
        /// <returns></returns>
        public apertiumDictionaryResult query(String token, apertiumDictQueryScope scope = apertiumDictQueryScope.startingWith, apertiumDictNeedleSide side = apertiumDictNeedleSide.native)
        {
            apertiumDictionaryResult output = new apertiumDictionaryResult();
            String query = makeQuery(token, scope, side);

            fileTextSearchResult res = dictionaryOperator.Search(query, true, 50, RegexOptions.IgnoreCase);

            foreach (var pair in res)
            {
                output.addLine(pair.Value);
            }

            return(output);
        }