예제 #1
0
        private List <ClausesTree> genTree(ISentence sentence, int[] bestVariantsNombers, Dictionary <int, List <IRelation> > rDict)
        {
            List <ClausesTree> treeRoots = new List <ClausesTree>();

            //находим корни синтаксического дерева
            for (int i = 0; i < sentence.ClausesCount; i++)
            {
                Clause clo = sentence.get_Clause(i);
                if (clo.RelativeWord == -1)//не всегда это признак корня синтаксического дерева!!!
                {
                    treeRoots.Add(new ClausesTree(i, 0, rDict[i], sentence));
                }
            }
            //к корням присоединяем остальные клаузы
            List <int> roorToDel = new List <int>();

            for (int i = 0; i < treeRoots.Count; i++)
            {
                treeRoots[i].backToTheRoots(treeRoots[i], sentence, rDict, true, true, roorToDel);
            }
            for (int i = 0; i < treeRoots.Count; i++)
            {
                if (roorToDel.Contains(treeRoots[i].cloNumber))
                {
                    treeRoots.RemoveAt(i);
                }
            }
            return(treeRoots);
        }
예제 #2
0
 /// <summary>
 /// Строит массив в котором содержатся номера лучших вариантов
 /// клауз данного предложения (что считается лучшим - спросить у Сокирко)
 /// </summary>
 /// <param name="sentence"></param>
 /// <returns></returns>
 private int[] getBestVariantsNombers(ISentence sentence)
 {
     int[] bestVariantsNombers = new int[sentence.ClausesCount];
     for (int i = 0; i < sentence.ClausesCount; i++)
     {
         IClause clo        = sentence.get_Clause(i);
         int     bestWeight = 0;//Int32.MaxValue;//0;//!!!
         for (int j = 0; j < clo.VariantsCount; j++)
         {
             ClauseVariant cloVar = clo.get_ClauseVariant(j);
             if (bestWeight < cloVar.VariantWeight)
             {
                 bestWeight             = cloVar.VariantWeight;
                 bestVariantsNombers[i] = j;
             }
         }
     }
     return(bestVariantsNombers);
 }