예제 #1
0
        private void GetAllResult(ref Session session)
        {
            string final_query = GenerateAllOsearchQuery(session);
            //var results = oSearchClient.Query(final_query);
            var results = SearchObjectStoreClient.Query(final_query);
            List <MovieEntity> format_results = new List <MovieEntity>();

            foreach (var item in results)
            {
                format_results.Add(new MovieEntity(item));
            }
            session.candidate_movies = format_results.Distinct().ToList();
            session.candidate_movies.Sort();
        }
예제 #2
0
        // wangbaoqiang as artist and director
        // DEPRECATED, use DialogManager.ClarifyArtistDirector instead
        private void DealArtistDirectorDuplicate()
        {
            List <string> duplicate_name = new List <string>();

            foreach (string art in carried_artist)
            {
                foreach (string dir in carried_director)
                {
                    if (art.Equals(dir))
                    {
                        duplicate_name.Add(art);
                    }
                }
            }
            if (duplicate_name.Count != 0)
            {
                foreach (string name in duplicate_name)
                {
                    List <string> osearch_query = oSearchQueryGenerator.GenerateSingleArtDirQuery(name);
                    //var as_an_art = oSearchClient.Query(osearch_query[0]);
                    var as_an_art = SearchObjectStoreClient.Query(osearch_query[0]);
                    //var as_a_dir = oSearchClient.Query(osearch_query[1]);
                    var  as_a_dir  = SearchObjectStoreClient.Query(osearch_query[1]);
                    bool is_an_art = (as_an_art.Count() > as_a_dir.Count()) ? true : false;
                    if (is_an_art)
                    {
                        carried_director.Remove(name);
                    }
                    else
                    {
                        carried_artist.Remove(name);
                    }
                }
                if (carried_artist.Count == 0)
                {
                    is_considerd[ParseStatus.Artist] = false;
                }
                if (carried_director.Count == 0)
                {
                    is_considerd[ParseStatus.Director] = false;
                }
            }
        }
예제 #3
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);
        }