public void Traffic(List <string> words) { foreach (string word in words) { bool isReg; InnerPos[] curPos = this.POS.GetPos(word, out isReg); InnerPos[] nextPos = this.POS.GetPos(word, out isReg); if (curPos.Length != 1) { continue; } InnerPos pos1 = curPos[0]; if (pos1 == InnerPos.POS_UNK) { continue; } if (nextPos.Length != 1) { continue; } InnerPos pos2 = (InnerPos)nextPos[0]; if (pos2 == InnerPos.POS_UNK) { continue; } DualityWordBin bin = new DualityWordBin(pos1, pos2); Hit(bin); } }
static public PosEnum InnertPosToPos(InnerPos inPos) { if (inPos == InnerPos.POS_UNK) { return(PosEnum.POS_UNK); } return((PosEnum)(0x01 << (int)inPos)); }
/// <summary> /// 增加单词的词性 /// </summary> /// <param name="word">单词</param> /// <param name="pos">词性</param> public void AddWordPos(String word, int pos) { if (word == null) { return; } if (word.Length == 1) { _OneCharTable[word] = true; } List <PosEnum> list = GetPosList(pos); InnerPos[] inPosList = new InnerPos[list.Count]; for (int i = 0; i < inPosList.Length; i++) { inPosList[i] = GetInnerPos((PosEnum)list[i]); } _PosTable[word] = inPosList; }
public DualityWordBin(InnerPos pos1, InnerPos pos2) { _Pos1 = pos1; _Pos2 = pos2; HashCode = (int)pos1 * 64 + (int)pos2; }