Exemplo n.º 1
0
        //逆向最长匹配
        public string BackSplitting(RowFirstDynamicArray <ChainContent> m_segGraph)
        {
            string abc  = "";
            int    nCol = m_segGraph.ColumnCount - 1;
            int    nRow = m_segGraph.RowCount - 1;

            //ChainItem<ChainContent> dfg = m_segGraph.GetElement(m_segGraph.RowCount-1, m_segGraph.ColumnCount-1);
            //List<ChainItem<ChainContent>> ab = new List<ChainItem<ChainContent>>();
            while (nCol > 1)
            {
                for (int i = 0; i <= nRow; i++)
                {
                    if (null != m_segGraph.GetElement(i, nCol))
                    {
                        if (abc == "")
                        {
                            abc = m_segGraph.GetElement(i, nCol).Content.sWord;
                        }
                        else
                        {
                            abc = m_segGraph.GetElement(i, nCol).Content.sWord + "/" + abc;
                        } nCol = i;
                        break;
                    }
                }
            }
            return(abc);
        }
Exemplo n.º 2
0
 //逆向最长匹配
 public string BackSplitting(RowFirstDynamicArray<ChainContent> m_segGraph)
 {
     string abc = "";
     int nCol = m_segGraph.ColumnCount-1;
     int nRow = m_segGraph.RowCount-1;
     //ChainItem<ChainContent> dfg = m_segGraph.GetElement(m_segGraph.RowCount-1, m_segGraph.ColumnCount-1);
     //List<ChainItem<ChainContent>> ab = new List<ChainItem<ChainContent>>();
     while (nCol > 1)
     {
         for (int i = 0; i <=nRow; i++)
         {
             if (null != m_segGraph.GetElement(i, nCol))
             {
                 if (abc == "") { abc = m_segGraph.GetElement(i, nCol).Content.sWord; }
                 else{
                 abc = m_segGraph.GetElement(i, nCol).Content.sWord + "/" + abc;
                 }nCol = i;
                 break;
             }
         }
     }
     return abc;
 }
Exemplo n.º 3
0
        //正向最长匹配
        public string ForwardSplitting(RowFirstDynamicArray<ChainContent> m_segGraph)
        {
            string abc = "";
            // =GetSegGraph();
            int currcol = 0;
            ChainItem<ChainContent> dfg= m_segGraph.GetElement(0, 1);
            ChainItem<ChainContent> aa = dfg.next;
            while (null != aa.next)
            {
                if (aa.next.row == aa.row)
                {
                    currcol = aa.next.col;
                    aa = aa.next;
                }
                else
                {
                    abc += aa.Content.sWord  ;
                    currcol = aa.col;
                    aa = m_segGraph.GetFirstElementOfRow(currcol);
                    break;
                }
            }

            while (null != aa.next)
            {
                if (aa.next.row == aa.row)
                {
                    currcol = aa.next.col;
                    aa = aa.next;
                }
                else
                {
                    abc += "/"+aa.Content.sWord ;
                    currcol = aa.col;
                    aa = m_segGraph.GetFirstElementOfRow(currcol);
                }

            }
            return abc;
        }
Exemplo n.º 4
0
        //正向最长匹配
        public string ForwardSplitting(RowFirstDynamicArray <ChainContent> m_segGraph)
        {
            string abc = "";
            // =GetSegGraph();
            int currcol = 0;
            ChainItem <ChainContent> dfg = m_segGraph.GetElement(0, 1);
            ChainItem <ChainContent> aa  = dfg.next;

            while (null != aa.next)
            {
                if (aa.next.row == aa.row)
                {
                    currcol = aa.next.col;
                    aa      = aa.next;
                }
                else
                {
                    abc    += aa.Content.sWord;
                    currcol = aa.col;
                    aa      = m_segGraph.GetFirstElementOfRow(currcol);
                    break;
                }
            }

            while (null != aa.next)
            {
                if (aa.next.row == aa.row)
                {
                    currcol = aa.next.col;
                    aa      = aa.next;
                }
                else
                {
                    abc    += "/" + aa.Content.sWord;
                    currcol = aa.col;
                    aa      = m_segGraph.GetFirstElementOfRow(currcol);
                }
            }
            return(abc);
        }
      //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;
      }