Esempio n. 1
0
        protected List <SynSet> GetCandidateSynSets(WordNet.WordNet wordNet, FsmMorphologicalAnalyzer fsm,
                                                    List <ParseNodeDrawable> leafList, int index)
        {
            LayerInfo twoPrevious = null, previous = null, current, twoNext = null, next = null;
            var       synSets = new List <SynSet>();

            current = leafList[index].GetLayerInfo();
            if (index > 1)
            {
                twoPrevious = leafList[index - 2].GetLayerInfo();
            }

            if (index > 0)
            {
                previous = leafList[index - 1].GetLayerInfo();
            }

            if (index != leafList.Count - 1)
            {
                next = leafList[index + 1].GetLayerInfo();
            }

            if (index < leafList.Count - 2)
            {
                twoNext = leafList[index + 2].GetLayerInfo();
            }

            synSets = wordNet.ConstructSynSets(current.GetMorphologicalParseAt(0).GetWord().GetName(),
                                               current.GetMorphologicalParseAt(0), current.GetMetamorphicParseAt(0), fsm);
            if (twoPrevious?.GetMorphologicalParseAt(0) != null && previous?.GetMorphologicalParseAt(0) != null)
            {
                synSets.AddRange(wordNet.ConstructIdiomSynSets(twoPrevious.GetMorphologicalParseAt(0),
                                                               previous.GetMorphologicalParseAt(0), current.GetMorphologicalParseAt(0),
                                                               twoPrevious.GetMetamorphicParseAt(0), previous.GetMetamorphicParseAt(0),
                                                               current.GetMetamorphicParseAt(0), fsm));
            }

            if (previous?.GetMorphologicalParseAt(0) != null && next?.GetMorphologicalParseAt(0) != null)
            {
                synSets.AddRange(wordNet.ConstructIdiomSynSets(previous.GetMorphologicalParseAt(0),
                                                               current.GetMorphologicalParseAt(0), next.GetMorphologicalParseAt(0),
                                                               previous.GetMetamorphicParseAt(0), current.GetMetamorphicParseAt(0),
                                                               next.GetMetamorphicParseAt(0), fsm));
            }

            if (next?.GetMorphologicalParseAt(0) != null && twoNext?.GetMorphologicalParseAt(0) != null)
            {
                synSets.AddRange(wordNet.ConstructIdiomSynSets(current.GetMorphologicalParseAt(0),
                                                               next.GetMorphologicalParseAt(0), twoNext.GetMorphologicalParseAt(0),
                                                               current.GetMetamorphicParseAt(0), next.GetMetamorphicParseAt(0),
                                                               twoNext.GetMetamorphicParseAt(0), fsm));
            }

            if (previous?.GetMorphologicalParseAt(0) != null)
            {
                synSets.AddRange(wordNet.ConstructIdiomSynSets(previous.GetMorphologicalParseAt(0),
                                                               current.GetMorphologicalParseAt(0),
                                                               previous.GetMetamorphicParseAt(0), current.GetMetamorphicParseAt(0), fsm));
            }

            if (next?.GetMorphologicalParseAt(0) != null)
            {
                synSets.AddRange(wordNet.ConstructIdiomSynSets(current.GetMorphologicalParseAt(0),
                                                               next.GetMorphologicalParseAt(0),
                                                               current.GetMetamorphicParseAt(0), next.GetMetamorphicParseAt(0), fsm));
            }

            return(synSets);
        }
        protected List <SynSet> GetCandidateSynSets(WordNet.WordNet wordNet, FsmMorphologicalAnalyzer fsm,
                                                    AnnotatedSentence.AnnotatedSentence sentence, int index)
        {
            AnnotatedWord twoPrevious = null, previous = null, current, twoNext = null, next = null;
            var           synSets = new List <SynSet>();

            current = (AnnotatedWord)sentence.GetWord(index);
            if (index > 1)
            {
                twoPrevious = (AnnotatedWord)sentence.GetWord(index - 2);
            }

            if (index > 0)
            {
                previous = (AnnotatedWord)sentence.GetWord(index - 1);
            }

            if (index != sentence.WordCount() - 1)
            {
                next = (AnnotatedWord)sentence.GetWord(index + 1);
            }

            if (index < sentence.WordCount() - 2)
            {
                twoNext = (AnnotatedWord)sentence.GetWord(index + 2);
            }

            synSets = wordNet.ConstructSynSets(current.GetParse().GetWord().GetName(),
                                               current.GetParse(), current.GetMetamorphicParse(), fsm);
            if (twoPrevious?.GetParse() != null && previous?.GetParse() != null)
            {
                synSets.AddRange(wordNet.ConstructIdiomSynSets(twoPrevious.GetParse(), previous.GetParse(),
                                                               current.GetParse(),
                                                               twoPrevious.GetMetamorphicParse(), previous.GetMetamorphicParse(), current.GetMetamorphicParse(),
                                                               fsm));
            }

            if (previous?.GetParse() != null && next?.GetParse() != null)
            {
                synSets.AddRange(wordNet.ConstructIdiomSynSets(previous.GetParse(), current.GetParse(), next.GetParse(),
                                                               previous.GetMetamorphicParse(), current.GetMetamorphicParse(), next.GetMetamorphicParse(), fsm));
            }

            if (next?.GetParse() != null && twoNext?.GetParse() != null)
            {
                synSets.AddRange(wordNet.ConstructIdiomSynSets(current.GetParse(), next.GetParse(), twoNext.GetParse(),
                                                               current.GetMetamorphicParse(), next.GetMetamorphicParse(), twoNext.GetMetamorphicParse(), fsm));
            }

            if (previous?.GetParse() != null)
            {
                synSets.AddRange(wordNet.ConstructIdiomSynSets(previous.GetParse(), current.GetParse(),
                                                               previous.GetMetamorphicParse(), current.GetMetamorphicParse(), fsm));
            }

            if (next?.GetParse() != null)
            {
                synSets.AddRange(wordNet.ConstructIdiomSynSets(current.GetParse(), next.GetParse(),
                                                               current.GetMetamorphicParse(), next.GetMetamorphicParse(), fsm));
            }

            return(synSets);
        }