/// <summary> /// 人名和前面的词词性匹配 /// </summary> /// <param name="nextStr"></param> /// <returns></returns> public bool MatchNameInTail(String preStr) { bool isReg; T_INNER_POS[] preList = _POS.GetPos(preStr, out isReg); if (preList.Length == 0) { return(false); } foreach (T_INNER_POS pre in preList) { if (pre == T_INNER_POS.POS_UNK) { continue; } T_POSBin posBin = new T_POSBin(pre, T_INNER_POS.POS_D_N); if (_PosBinTbl[posBin.HashCode] != null) { return(true); } posBin = new T_POSBin(pre, T_INNER_POS.POS_A_NR); if (_PosBinTbl[posBin.HashCode] != null) { return(true); } } return(false); }
/// <summary> /// 人名和后面的词词性匹配 /// </summary> /// <param name="str1"></param> /// <param name="str2"></param> /// <returns></returns> public bool MatchNameInHead(String nextStr) { bool isReg; T_INNER_POS[] nextList = _POS.GetPos(nextStr, out isReg); if (nextList.Length == 0) { return(false); } foreach (T_INNER_POS next in nextList) { if (next == T_INNER_POS.POS_UNK) { continue; } T_POSBin posBin = new T_POSBin(T_INNER_POS.POS_D_N, next); if (_PosBinTbl[posBin.HashCode] != null) { return(true); } posBin = new T_POSBin(T_INNER_POS.POS_A_NR, next); if (_PosBinTbl[posBin.HashCode] != null) { return(true); } } return(false); }
private void Hit(T_POSBin posBin) { T_POSBin bin = (T_POSBin)_PosBinTbl[posBin.HashCode]; if (bin == null) { bin = new T_POSBin(posBin._Pos1, posBin._Pos2); bin._Count = 1; _PosBinTbl[bin.HashCode] = bin; _PosBinList.Add(bin); } else { bin._Count++; } }
public int CompareTo(object obj) { T_POSBin dest = (T_POSBin)obj; if (dest._Count == _Count) { return(0); } else if (dest._Count > _Count) { return(1); } else { return(-1); } }
public bool Match(String str1, String str2) { bool isReg; T_INNER_POS[] posList1 = _POS.GetPos(str1, out isReg); if (!isReg) { return(false); } T_INNER_POS[] posList2 = _POS.GetPos(str2, out isReg); if (!isReg) { return(false); } if (posList1.Length == 0 || posList2.Length == 0) { return(false); } foreach (T_INNER_POS pos1 in posList1) { if (pos1 == T_INNER_POS.POS_UNK) { continue; } foreach (T_INNER_POS pos2 in posList2) { if (pos2 == T_INNER_POS.POS_UNK) { continue; } T_POSBin posBin = new T_POSBin(pos1, pos2); if (_PosBinTbl[posBin.HashCode] != null) { return(true); } } } return(false); }
public void Traffic(List <String> words) { for (int i = 0; i < words.Count - 1; i++) { bool isReg; T_INNER_POS[] curPos = _POS.GetPos((String)words[i], out isReg); T_INNER_POS[] nextPos = _POS.GetPos((String)words[i + 1], out isReg); //ArrayList curList = _POS.GetPosList(curPos); if (curPos.Length != 1) { continue; } T_INNER_POS pos1 = curPos[0]; if (pos1 == T_INNER_POS.POS_UNK) { continue; } //ArrayList nextList = _POS.GetPosList(nextPos); if (nextPos.Length != 1) { continue; } T_INNER_POS pos2 = (T_INNER_POS)nextPos[0]; if (pos2 == T_INNER_POS.POS_UNK) { continue; } T_POSBin bin = new T_POSBin(pos1, pos2); Hit(bin); } }