void Start()
    {
        // Spheres of Influence
        gameWorldRadius = 5000.0f;
        sentryRadius = 0.0f;
        ionRadius = 0.0f;

        // Gravity Variables
        gravityPolarity = polarity.Pull;
        gravityConstant = 6.673f * Mathf.Pow(10.0f, -11.0f);
        gravityWellMass = 5.058f * Mathf.Pow(10.0f, 18.0f);
    }
Exemple #2
0
        public void AddNeighbor(string nbor, string linke_kw, polarity mutual_pole)
        {
            if (!Neighbors.ContainsKey(nbor))
            {
                Neighbors.Add(nbor, new kwp(mutual_pole));
            }

            Neighbors[nbor].kw += linke_kw + ",";
            Neighbors[nbor].Weight++;
            if (Neighbors[nbor].Pole != mutual_pole)
            {
                Neighbors[nbor].Pole = polarity.opn;
            }
        }
Exemple #3
0
        public void genEEgraph(string reportPath, int kwLimitThreshold = 350, int entityOccurThreshold = 2, double polarityThresh = 0.35, bool PoleInvariant = false, bool NoSelfEdge = true)
        {
            if (EkwEgg == null)
            {
                EkwEgg = new Dictionary <string, EEVertex>(StringComparer.InvariantCultureIgnoreCase);
            }
            Console.WriteLine("Generating EE graph");

            int legitKWCnt = 0;

            foreach (KeyValuePair <string, kwEo> cnt in kwLexicon)
            {
                if (cnt.Value.E.Count < kwLimitThreshold)
                {
                    legitKWCnt++;
                }
            }
            Console.WriteLine("from " + legitKWCnt + " legit kw");
            DateTime startTime = DateTime.Now;

            foreach (KeyValuePair <string, EkwO> ekwo in EkwDict)
            {
                string E      = ekwo.Key;
                EkwO   ekwp   = ekwo.Value;
                double pScore = ekwp.PScore;

                if (ekwp.Occur <= entityOccurThreshold)
                {
                    continue;
                }

                EkwEgg.Add(E, new EEVertex(E));

                foreach (string keyword in ekwp.kw.Keys)
                {
                    //got the linker
                    if (kwLexicon.ContainsKey(keyword) && kwLexicon[keyword].E.Count < kwLimitThreshold)
                    {
                        Dictionary <string, Meta> PotentialNeighbors = kwLexicon[keyword].E;
                        foreach (string nborE in PotentialNeighbors.Keys)
                        {
                            if (nborE == E && NoSelfEdge)
                            {
                                continue;
                            }
                            double   nborPScore = EkwDict[nborE].PScore;
                            polarity pole       = polarity.opn;
                            if (nborPScore >= polarityThresh && pScore >= polarityThresh)
                            {
                                pole = polarity.pos;
                            }
                            else if (nborPScore <= -polarityThresh && pScore <= -polarityThresh)
                            {
                                pole = polarity.neg;
                            }
                            else if (nborPScore > 0 && pScore > 0)
                            {
                                if (nborPScore + pScore > 2 * polarityThresh)
                                {
                                    pole = polarity.pos;
                                }
                                else
                                {
                                    pole = polarity.obj;
                                }
                            }
                            else if (nborPScore < 0 && pScore < 0)
                            {
                                if (nborPScore + pScore > 2 * polarityThresh)
                                {
                                    pole = polarity.neg;
                                }
                                else
                                {
                                    pole = polarity.obj;
                                }
                            }
                            else if (nborPScore == 0 || pScore == 0)
                            {
                                pole = polarity.obj;
                            }

                            if (pole != polarity.opn || PoleInvariant)
                            {
                                EkwEgg[E].AddNeighbor(nborE, keyword, pole);
                            } //added nbor
                        }     //finding nbors by kw
                    }         //this kw is in lex
                }             //iterating over kw
            }                 //iterating over EkwDict

            //cleanup
            foreach (string node in EkwEgg.Keys)
            {
                string[] nborvs = new string[EkwEgg[node].Neighbors.Keys.Count];
                int      i      = 0;
                foreach (string nbk in EkwEgg[node].Neighbors.Keys)
                {
                    nborvs[i++] = nbk;
                }
                foreach (string nbork in nborvs)
                {
                    if (!EkwEgg.ContainsKey(nbork))
                    {
                        EkwEgg[node].Neighbors.Remove(nbork);
                    }
                }
            }
            Console.WriteLine("and " + EkwEgg.Count + " entities");
            Console.WriteLine("EkwEG time to generate EE graph: " + (TimeSpan)(DateTime.Now - startTime));

            StreamWriter fs = new StreamWriter(reportPath + "-" + kwLimitThreshold + "," + entityOccurThreshold + ".EkwEGg.csv", false);

            foreach (KeyValuePair <string, EEVertex> evert in EkwEgg)
            {
                fs.Write(evert.Key + "," + evert.Value.Neighbors.Count + ",");
                foreach (string nbor in evert.Value.Neighbors.Keys)
                {
                    fs.Write(nbor + ";");
                }
                fs.WriteLine();
            }
            fs.Close();
            Console.WriteLine("EkwEG time to store & generate EE graph: " + (TimeSpan)(DateTime.Now - startTime));
        }
Exemple #4
0
 public kwp(polarity pole)
 {
     Weight = 0; kw = ""; Pole = pole;
 }
Exemple #5
0
        public void genEEgraph(string reportPath, int kwLimitThreshold = 350, int entityOccurThreshold = 2, double polarityThresh = 0.45, bool PoleInvariant = false)
        {
            if (EkwEgg == null)
            {
                EkwEgg = new Dictionary <string, EEVertex>();
            }
            DateTime startTime = DateTime.Now;

            foreach (KeyValuePair <string, EkwO> ekwo in EkwDict)
            {
                string E      = ekwo.Key;
                EkwO   ekwp   = ekwo.Value;
                double pScore = ekwp.PScore;

                if (ekwp.Occur <= entityOccurThreshold)
                {
                    continue;
                }

                EkwEgg.Add(E, new EEVertex(E));

                foreach (string keyword in ekwp.kw.Keys)
                {
                    //got the linker
                    if (kwLexicon.ContainsKey(keyword) && kwLexicon[keyword].E.Count < kwLimitThreshold)
                    {
                        Dictionary <string, Meta> PotentialNeighbors = kwLexicon[keyword].E;
                        foreach (string nborE in PotentialNeighbors.Keys)
                        {
                            double   nborPScore = EkwDict[nborE].PScore;
                            polarity pole       = polarity.opn;
                            if (nborPScore >= polarityThresh && pScore >= polarityThresh)
                            {
                                pole = polarity.pos;
                            }
                            else if (nborPScore <= -polarityThresh && pScore <= -polarityThresh)
                            {
                                pole = polarity.neg;
                            }
                            else if (nborPScore > 0 && pScore > 0)
                            {
                                if (nborPScore + pScore > 2 * polarityThresh)
                                {
                                    pole = polarity.pos;
                                }
                                else
                                {
                                    pole = polarity.obj;
                                }
                            }
                            else if (nborPScore < 0 && pScore < 0)
                            {
                                if (nborPScore + pScore > 2 * polarityThresh)
                                {
                                    pole = polarity.neg;
                                }
                                else
                                {
                                    pole = polarity.obj;
                                }
                            }
                            else if (nborPScore == 0 || pScore == 0)
                            {
                                pole = polarity.obj;
                            }

                            if (pole != polarity.opn || PoleInvariant)
                            {
                                EkwEgg[E].AddNeighbor(nborE, keyword, pole);
                            } //added nbor
                        }     //finding nbors by kw
                    }         //this kw is in lex
                }             //iterating over kw
            }                 //iterating over EkwDict

            DateTime endTime = DateTime.Now;
            TimeSpan ts      = endTime - startTime;

            Console.WriteLine("EkwEG time to generate EE graph: " + ts);

            StreamWriter fs = new StreamWriter(reportPath + ".EkwEGg.csv", false);

            foreach (KeyValuePair <string, EEVertex> evert in EkwEgg)
            {
                fs.Write(evert.Key + "," + evert.Value.Neighbors.Count + ",");
                foreach (string nbor in evert.Value.Neighbors.Keys)
                {
                    fs.Write(nbor + ";");
                }
                fs.WriteLine();
            }
        }