Ejemplo n.º 1
0
 /// <summary>
 /// Returns ID of the token specified
 /// </summary>
 /// <param name="str">The token</param>
 /// <returns></returns>
 public int GetTokenID(string str)
 {
     if (TokenID.ContainsKey(str))
     {
         return TokenID[str];
     }
     else
     {
         return AddToken(str);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Registers new token, returns assigned ID
 /// </summary>
 /// <param name="str">The string.</param>
 /// <returns></returns>
 public int AddToken(string str, Int32 frequency = 1)
 {
     if (!TokenID.ContainsKey(str))
     {
         Tokens.Add(str);
         TokenID[str] = Tokens.Count - 1;
         TokenFrequency[str] = frequency;
         InvokeChanged();
         return TokenID[str];
     }
     return -1;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds oscore point/s to the token frequency. If the token wasn't registered with the dictionary, it will register it automatically.
        /// </summary>
        /// <param name="token">The token - token in the dictionary</param>
        /// <param name="score">The score - points to be added.</param>
        public void CountToken(String token, Int32 score = 1)
        {
            if (!TokenID.ContainsKey(token))
            {
                Tokens.Add(token);
                TokenID[token] = TokenID.Count;
                TokenFrequency[token] = 0;
            }
            TokenFrequency[token] = TokenFrequency[token] + score;

            InvokeChanged();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns list of IDs for given token list
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns></returns>
        public List<Int32> GetTokenIDs(IEnumerable<String> input)
        {
            List<Int32> output = new List<int>();

            foreach (String tkn in input)
            {
                if (TokenID.ContainsKey(tkn))
                {
                    output.Add(TokenID[tkn]);
                }
            }
            return output;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the token by identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns></returns>
        public List<Int32> GetIDsByTokens(IEnumerable<String> tkns)
        {
            List<Int32> output = new List<Int32>();

            foreach (String i in tkns)
            {
                if (TokenID.ContainsKey(i))
                {
                    output.Add(TokenID[i]);
                }
            }

            return output;
        }
Ejemplo n.º 6
0
 public Boolean Contains(String token)
 {
     return TokenID.ContainsKey(token);
 }