Exemplo n.º 1
0
        public Associations Associate(SGF query, List <SGF> queryResult)
        {
            //add new queries
            AddQueriesFromResultsSgf(queryResult);

            //remove old query
            Queries.Remove(query);

            //add graph edges
            var queryDecomposed = query.Decompose();

            foreach (var sgf in queryResult)
            {
                foreach (var msgfTo in sgf.Decompose())
                {
                    foreach (var msgfFrom in queryDecomposed)
                    {
                        Graph.AddEdge(msgfFrom, msgfTo);
                    }
                }
            }

            //update limits
            UnitsLimit.UpdateCurrentValues(
                (uint)Math.Max(QueriesList.Count(), Queries.Count)
                , Graph.GetNodeCount()
                , Graph.GetEdgeCount());

            return(this);
        }
Exemplo n.º 2
0
 public Associations InitAssociations(SGF sgf)
 {
     foreach (var msgf in sgf.Decompose())
     {
         StartNodes.Add(msgf);
     }
     return(AddQueriesFromResultsSgf(new List <SGF> {
         sgf
     }));
 }
Exemplo n.º 3
0
        public static List <SGF> GenQueries(SGF sgf)
        {
            var list = sgf.Decompose();
            var ret  = new List <SGF>();
            {//gen words
                foreach (var msgf in list)
                {
                    ret.Add(
                        new SGF().AggregateFrom(
                            new List <MSGF> {
                        msgf
                    }));
                }
            }
            {//gen pairs
                MSGF a1 = null;
                foreach (var msgf in list)
                {
                    if (a1 != null)
                    {
                        ret.Add(
                            new SGF().AggregateFrom(
                                new List <MSGF> {
                            a1, msgf
                        }.OrderBy(l => l.GetContent())
                                .ToList()));
                    }
                    a1 = msgf;
                }
            }
            {//gen tripples
                MSGF a1 = null, a2 = null;
                foreach (var msgf in list)
                {
                    if (a1 != null && a2 != null)
                    {
                        ret.Add(
                            new SGF().AggregateFrom(
                                new List <MSGF> {
                            a1, a2, msgf
                        }.OrderBy(l => l.GetContent())
                                .ToList()));
                    }
                    a1 = a2;
                    a2 = msgf;
                }
            }
            var rnd = new Random();

            return
                (ret.OrderBy(x => rnd.Next())
                 .Take(Math.Max(3, (ret.Count + 9) / 10))
                 .ToList());
        }
Exemplo n.º 4
0
        public QueryAsyncRequest(SGF query)
        {
            string searchQuery = query.Decompose().Select(x => x.GetContent()).Aggregate((a, b) => a + " " + b);
            string fullUrl     = BeginUrl + WebUtility.UrlEncode(searchQuery);

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(fullUrl);

            InitHttpWebRequest(ref request);

            RequestProcessor = new Thread(() =>
            {
                DoRequest(request);
            });

            RequestProcessor.Start();
        }