PanGu.Dict.WordDictionary.UpdateWord C# (CSharp) Method

UpdateWord() public method

public UpdateWord ( String word, double frequency, POS pos ) : void
word String
frequency double
pos POS
return void
        public void UpdateWord(String word, double frequency, POS pos)
        {
            string key = word.ToLower();

            if (key.Length == 1)
            {
                if (_FirstCharDict.ContainsKey(key[0]))
                {
                    _FirstCharDict[key[0]].Word = word;
                    _FirstCharDict[key[0]].Frequency = frequency;
                    _FirstCharDict[key[0]].Pos = pos;

                    return;
                }
                else
                {
                    return;
                }
            }

            if (key.Length == 2)
            {
                uint doubleChar = ((uint)key[0] * 65536) + key[1];
                if (_DoubleCharDict.ContainsKey(doubleChar))
                {
                    _DoubleCharDict[doubleChar].Word = word;
                    _DoubleCharDict[doubleChar].Frequency = frequency;
                    _DoubleCharDict[doubleChar].Pos = pos;

                    return;
                }
                else
                {
                    return;
                }
            }

            if (_WordDict == null)
            {
                return;
            }

            if (!_WordDict.ContainsKey(key))
            {
                return;
            }

            _WordDict[key].Word = word;
            _WordDict[key].Frequency = frequency;
            _WordDict[key].Pos = pos;
        }