//Unknown word recognition //pWordSegResult:word Segmentation result; //graphOptimum: The optimized segmentation graph //graphSeg: The original segmentation graph public bool Recognition(WordResult[] pWordSegResult, RowFirstDynamicArray <ChainContent> graphOptimum, List <AtomNode> atomSegment, WordDictionary dictCore) { ChainItem <ChainContent> item; int nStartPos = 0, j = 0, nAtomStart, nAtomEnd, nPOSOriginal; double dValue; m_roleTag.POSTagging(pWordSegResult, dictCore, m_dict); //Tag the segmentation with unknown recognition roles according the core dictionary and unknown recognition dictionary for (int i = 0; i < m_roleTag.m_nUnknownWordsCount; i++) { while (j < atomSegment.Count && nStartPos < m_roleTag.m_nUnknownWords[i, 0]) { nStartPos += atomSegment[j++].sWord.Length; } nAtomStart = j; while (j < atomSegment.Count && nStartPos < m_roleTag.m_nUnknownWords[i, 1]) { nStartPos += atomSegment[j++].sWord.Length; } nAtomEnd = j; if (nAtomStart < nAtomEnd) { item = graphOptimum.GetElement(nAtomStart, nAtomEnd); if (item != null) { dValue = item.Content.eWeight; nPOSOriginal = item.Content.nPOS; } else { dValue = Predefine.INFINITE_VALUE; } if (dValue > m_roleTag.m_dWordsPossibility[i]) { //Set the element with less frequency graphOptimum.SetElement(nAtomStart, nAtomEnd, new ChainContent(m_roleTag.m_dWordsPossibility[i], m_nPOS, m_sUnknownFlags)); } } } return(true); }
public List <WordResult[]> Segment(string sentence, int nKind) { OnBeginSegment(sentence); m_pNewSentence = Predefine.SENTENCE_BEGIN + sentence + Predefine.SENTENCE_END; int nResultCount = m_Seg.BiSegment(m_pNewSentence, m_dSmoothingPara, nKind); for (int i = 0; i < nResultCount; i++) { if (this.PersonRecognition) { m_uPerson.Recognition(m_Seg.m_pWordSeg[i], m_Seg.m_graphOptimum, m_Seg.atomSegment, m_dictCore); } if (this.TransPersonRecognition) { m_uTransPerson.Recognition(m_Seg.m_pWordSeg[i], m_Seg.m_graphOptimum, m_Seg.atomSegment, m_dictCore); } if (this.PlaceRecognition) { m_uPlace.Recognition(m_Seg.m_pWordSeg[i], m_Seg.m_graphOptimum, m_Seg.atomSegment, m_dictCore); } } OnPersonAndPlaceRecognition(m_Seg.m_graphOptimum); m_Seg.BiOptimumSegment(1, m_dSmoothingPara); for (int i = 0; i < m_Seg.m_pWordSeg.Count; i++) { m_POSTagger.POSTagging(m_Seg.m_pWordSeg[i], m_dictCore, m_dictCore); } OnFinishSegment(m_Seg.m_pWordSeg); return(m_Seg.m_pWordSeg); }