Пример #1
0
        public PatternResponse(Query tagged_query, Pattern pattern)
        {
            raw_query  = tagged_query.raw_query;
            post_query = tagged_query.postagged_query;

            // used for generate database query
            entity_type = pattern.entity_type;
            property    = pattern.property;

            hop_num = pattern.hop_num;
        }
Пример #2
0
        public static List <string> GetColumnData(KBQAEntityType topic_type, string topic, string property)
        {
            List <string> ret = new List <string>();
            // filter which column
            string query_filter  = "";
            string result_filter = "";

            string[] edge_property_arr = property.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
            property = edge_property_arr[0];
            string rank_policy = "";

            switch (topic_type)
            {
            case KBQAEntityType.Celebrity:
            {
                if ("Act".Equals(property))
                {
                    query_filter = $@"(#:""{topic}Artists "")";
                }
                else
                {
                    query_filter = $@"(#:""{topic}Directors "")";
                }
                result_filter = "Name";
                break;
            }

            case KBQAEntityType.Movie:
            {
                query_filter  = $@"(#:""{topic}Name "")";
                result_filter = property;
                break;
            }

            case KBQAEntityType.RecentMovie:
            {
                query_filter  = "";
                rank_policy   = "recent";
                result_filter = property;
                break;
            }

            case KBQAEntityType.IsPublish:
            {
                query_filter  = $@"(#:""{topic}Name "")";
                result_filter = property;
                List <SnappsEntity> temp_res = (List <SnappsEntity>)SearchObjectStoreClient.Query(query_filter, rank_policy);
                int datetime = 0;
                try
                {
                    ret      = ParseResult(temp_res, result_filter);
                    datetime = int.Parse(ret[0]);
                    string publish_date = DateTime.ParseExact(ret[0], "yyyyMMdd", null).ToString("yyyy年MM月dd日");
                    return(int.Parse(DateTime.Now.ToString("yyyyMMdd")) >= datetime ?
                           new List <string> {
                            $"上映了,上映时间是{publish_date}"
                        } : new List <string> {
                            $"还没上映呢,上映时间是{publish_date}"
                        });
                }
                catch (Exception e)
                {
                    //Console.WriteLine($"Exception caught: {e}");
                    Utils.WriteError("Column Table has not this record!");
                }
                return(new List <string>());
            }
            }

            List <SnappsEntity> res = (List <SnappsEntity>)SearchObjectStoreClient.Query(query_filter, rank_policy);

            try
            {
                ret = ParseResult(res, result_filter);
            }
            catch (Exception e)
            {
                //Console.WriteLine($"Exception caught: {e}");
                Utils.WriteError("Column Table has not this record!");
            }
            return(ret);
        }
Пример #3
0
 public ColumnTableQueryInfo(KBQAEntityType t, string e, string p)
 {
     type     = t;
     entity   = e;
     property = p;
 }