Ejemplo n.º 1
0
 /// <summary>
 /// Collects all tokens and sums their frequencies with existing data in the dictionary
 /// </summary>
 /// <param name="input">The input.</param>
 public void MergeDictionary(TokenDictionary input)
 {
     foreach (KeyValuePair<string, int> pair in input.TokenFrequency)
     {
         CountToken(pair.Key, pair.Value);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Clones this instance.
 /// </summary>
 /// <returns></returns>
 public TokenDictionary Clone()
 {
     TokenDictionary output = new TokenDictionary();
     foreach (String token in Tokens)
     {
         output.TokenFrequency.Add(token, TokenFrequency[token]);
         output.TokenID.Add(token, TokenID[token]);
         output.Tokens.Add(token);
         output.InvokeChanged();
     }
     return output;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds the specified tokens.
        /// </summary>
        /// <param name="tokens">The tokens.</param>
        /// <param name="score">The score.</param>
        public void Add(TokenDictionary tokens, Double score)
        {
            if (tokens.Count == 0)
            {
                return;
            }

            foreach (String token in tokens.GetTokens())
            {
                Add(token, score, tokens.GetTokenFrequency(token));
            }
            //foreach ()
        }
Ejemplo n.º 4
0
        public void ProjectionEntry(SemanticNetworkDictionary output, TokenDictionary primary, TokenDictionary secondary)
        {
            double primarySizeFactor   = 1.GetRatio(primary.Count);   //1.GetRatio(primary.GetSumFrequency()) * 1.GetRatio(primary.Count);
            double secondarySizeFactor = 1.GetRatio(secondary.Count); //1.GetRatio(secondary.GetSumFrequency()) *

            List <string> primaryTokens   = primary.GetTokens();
            List <string> secondaryTokens = secondary.GetTokens();

            foreach (string token in primaryTokens)
            {
                double score = primary.GetTokenFrequency(token) * primarySizeFactor;
                output.AddNodeOrSum(token, score, 0);
            }

            foreach (string token in secondaryTokens)
            {
                double score = secondary.GetTokenFrequency(token) * secondarySizeFactor;
                output.AddNodeOrSum(token, score, 0);
            }

            foreach (string p_token in primaryTokens)
            {
                Int32 p_freq = primary.GetTokenFrequency(p_token);

                foreach (string s_token in secondaryTokens)
                {
                    Int32 s_freq = secondary.GetTokenFrequency(s_token);

                    double p2s_score = s_freq / p_freq;

                    freeGraphLinkBase link = new freeGraphLinkBase();
                    link.nodeNameA = p_token;
                    link.nodeNameB = s_token;
                    link.weight    = p2s_score;
                    link.type      = 0;

                    output.AddLinkOrSum(link);
                }
            }
        }