Esempio n. 1
0
        private Hit search(char[] seg, int begin, int end, Hit searchHit)
        {
            if (dictTreeNode == null)
            {
                searchHit.setUnmatch();
                return(searchHit);
            }
            Char        keyChar = seg[begin];
            DictSegment ds      = (DictSegment)dictTreeNode[keyChar];

            if (ds != null)
            {
                if (begin < end)
                {
                    return(ds.search(seg, begin + 1, end, searchHit));
                }
                if (begin == end)
                {
                    if (ds.NodeState == 1)
                    {
                        searchHit.setMatch();
                        searchHit.WordType = ds.WordType;
                    }
                    if (ds.hasNextNode())
                    {
                        searchHit.setPrefixMatch();
                    }
                }
            }
            else
            {
                searchHit.setUnmatch();
            }
            return(searchHit);
        }
Esempio n. 2
0
 private Dictionary()
 {
     assembly     = typeof(Dictionary).Assembly;
     hsNoise      = null;
     hsStop       = null;
     hsOtherDigit = null;
     hsCHNNumber  = null;
     hsNbSign     = null;
     hsConnector  = null;
     dictSeg      = null;
     dictSeg      = new DictSegment();
     initDictionary();
 }
Esempio n. 3
0
        public virtual void  addWord(char[] seg, int begin, int end, WordType wordType)
        {
            if (dictTreeNode == null)
            {
                dictTreeNode = new Hashtable(2, 0.8F);
            }
            Char        keyChar = seg[begin];
            DictSegment ds      = (DictSegment)dictTreeNode[keyChar];

            if (ds == null)
            {
                ds = new DictSegment();
                dictTreeNode[keyChar] = ds;
            }
            if (begin < end)
            {
                ds.addWord(seg, begin + 1, end, wordType);
            }
            else if (begin == end)
            {
                ds.NodeState = 1;
                ds.wordType.addWordType(wordType);
            }
        }