예제 #1
0
        /// <summary>
        /// Explores the token.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <returns></returns>
        public override tokenQueryResponse exploreToken(tokenQuery query)
        {
            getReady();

            tokenQueryResponse response   = new tokenQueryResponse(query, tokenQuerySourceEnum.ext_dict);
            List <DataRow>     matches    = new List <DataRow>();
            String             expression = "";

            foreach (DataTable dt in namedEntityDataSet.Tables)
            {
                expression = "";
                if (query.focus == contentTokenFlag.none)
                {
                    expression = dt.ExtendedProperties.getProperString(tokenResultEnum.query).Replace("".t(tokenResultEnum.needle), query.token);
                }
                else
                {
                    contentTokenFlag table_focus = (contentTokenFlag)dt.ExtendedProperties[tokenResultEnum.tokenFlag]; //.getProperEnum<contentTokenFlag>(contentTokenFlag.namedEntityKnown, );
                    if (table_focus.HasFlag(query.focus))
                    {
                        expression = dt.ExtendedProperties.getProperString(tokenResultEnum.query).Replace("".t(tokenResultEnum.needle), query.token);
                    }
                }

                if (expression != "")
                {
                    matches.AddRange(dt.Select(expression));
                }
            }

            foreach (DataRow dr in matches)
            {
                var fl = (contentTokenFlag)dr.Table.ExtendedProperties[tokenResultEnum.tokenFlag];
                response.flags.AddInstanceRange(fl.getEnumListFromFlags <contentTokenFlag>());
                response.dataRows.Add(dr);
                foreach (DataColumn dc in dr.Table.Columns)
                {
                    response.dataTokens.AddRangeUnique(dr[dc].toStringSafe().getTokens());
                }
            }

            if (response.flags.Count > 0)
            {
                response.setResponse("Known entity", "Flags earned: " + response.flags.toCsvInLine(";"));
            }
            else
            {
                response.setResponse(tokenQueryResultEnum.unknown_token);
            }

            return(response);
        }
예제 #2
0
        public override tokenQueryResponse exploreToken(tokenQuery query)
        {
            tokenQueryResponse response = new tokenQueryResponse(query, tokenQuerySourceEnum.ext_dict);

            if (imbLanguageFrameworkManager.serbian.CheckAgainstAlfabet(query.token))
            {
                response.setResponse(tokenQueryResultEnum.accept);
            }
            else
            {
                response.setResponse(tokenQueryResultEnum.dismiss);
            }
            query.responses[tokenQuerySourceEnum.imb_alfabetTest].Add(response);
            return(response);
        }
        public override tokenQueryResponse exploreToken(tokenQuery query)
        {
            tokenQueryResponse response = new tokenQueryResponse(query, tokenQuerySourceEnum.ext_dict);

            DataRow[] result = table.Select("token LIKE '" + query.token + "'");

            if (result.Any())
            {
                foreach (DataRow dr in result)
                {
                    wordnetTriplet triplet = new wordnetTriplet(dr.ItemArray);
                    var            tqr     = new tokenQueryResponse(query, tokenQuerySourceEnum.ext_wordnet);
                    tqr.metadata = triplet;
                    tqr.setResponse(triplet.token, triplet.meaning);
                    query.responses[tokenQuerySourceEnum.ext_wordnet].Add(tqr);
                }
            }

            return(response);
        }
        public override tokenQueryResponse exploreToken(tokenQuery query)
        {
            getReady();

            var response = new tokenQueryResponse(query, tokenQuerySourceEnum.ext_dict);

            DataRow[] result = table.Select("Token LIKE '" + query.token + "'");

            if (result.Any())
            {
                foreach (DataRow dr in result)
                {
                    dictTriplet triplet = new dictTriplet(__token: dr["token"].toStringSafe(), __meaning: dr["Meaning"].toStringSafe(), __code: dr["Code"].toStringSafe());
                    var         tqr     = new tokenQueryResponse(query, tokenQuerySourceEnum.ext_dict)
                    {
                        metadata = triplet
                    };
                    tqr.setResponse(triplet.token, triplet.meaning);
                    query.responses[tokenQuerySourceEnum.ext_wordnet].Add(tqr);
                }
            }

            return(response);
        }