Esempio n. 1
0
        public void AddWordCandidate(string word, IncrementalGAnalyzer condidateAnalyzer, IGAnlys_Candidates candidateHolder)
        {
            wordCandidateInfoDict.TryGetValue(word, out var wordCandInfos);
            if (wordCandInfos == null)
            {
                wordCandInfos = wordCandidateInfoDict[word] = new List <AnalyzerInfo>();
            }
            var info = wordCandInfos.Find((elem) => elem.condidateAnalyzer == condidateAnalyzer);

            if (info == null)
            {
                info = new AnalyzerInfo {
                    condidateAnalyzer = condidateAnalyzer
                };
                wordCandInfos.Add(info);
            }
            info.candidateHolders.Add(candidateHolder);
        }
Esempio n. 2
0
 public IGAnlys_ModifyBlock(IncrementalGAnalyzer _baseAnlys, IncrementalGAnalyzer _preMod, IncrementalGAnalyzer _postMod)
 {
     baseAnlys = _baseAnlys;
     preMod    = _preMod;
     postMod   = _postMod;
     if (preMod != null)
     {
         anaylzers.Add(new IGAnlys_Optional {
             baseAnalyzer = preMod
         });
     }
     anaylzers.Add(baseAnlys);
     if (postMod != null)
     {
         anaylzers.Add(new IGAnlys_Optional {
             baseAnalyzer = postMod
         });
     }
 }
Esempio n. 3
0
        public IncrementalGAnalyzer ModifyAnalyzer(IncrementalGAnalyzer anlys, ref bool doIgnoreNext, ref bool isUnreadableNext)
        {
            var result = anlys;

            if (doIgnoreNext)
            {
                result = new IGAnlys_IgnoreBlock {
                    baseAnalyzer = anlys
                };
            }
            else if (isUnreadableNext)
            {
                result = new IGAnlys_Unreadable {
                    lasyAnlys = anlys
                };
            }
            doIgnoreNext     = false;
            isUnreadableNext = false;
            return(result);
        }
Esempio n. 4
0
        void GenericReader.Conclude()
        {
            IncrementalGAnalyzer analyzer = FormsToAnlys(forms, isPolymorphicWord);

            if (preModifiers.Count > 0 || postModifiers.Count > 0)
            {
                IncrementalGAnalyzer premod  = null;
                IncrementalGAnalyzer postmod = null;
                if (preModifiers.Count > 0)
                {
                    //premod = new IGAnlys_RepeatableBlock { baseAnalyzer = FormsToAnlys(preModifiers), conjectionAnalyzer = cojunctionIGAnlys };
                    premod = FormsToAnlys(preModifiers, false);
                }
                if (postModifiers.Count > 0)
                {
                    //postmod = new IGAnlys_RepeatableBlock { baseAnalyzer = FormsToAnlys(postModifiers), conjectionAnalyzer = cojunctionIGAnlys };
                    postmod = FormsToAnlys(postModifiers, false);
                }
                var modBlock = new IGAnlys_ModifyBlock(analyzer, premod, postmod);
                analyzer = modBlock;
            }
            if (isEnumerable)
            {
                analyzer = new IGAnlys_RepeatableBlock {
                    baseAnalyzer = analyzer, conjectionAnalyzer = cojunctionIGAnlys, isConjectionOptional = isConjunctionOptional
                };
                analyzer = new IGAnlys_ResultClusterizer {
                    baseAnalyzer = analyzer
                };
            }
            if (attributes.Count > 0)
            {
                var metaAnlys = new IGAnlys_AddMeta {
                    baseAnalyzer = analyzer
                };
                foreach (var attribute in attributes)
                {
                    if (metaInfos.TryGetValue(attribute, out GrammarBlock gBlock))
                    {
                        metaAnlys.metas.Add(gBlock);
                    }
                }
                ;
                analyzer = metaAnlys;
            }
            foreach (var category in categoriess)
            {
                //gAnlysDict.categories[category].candidates.Add(analyzer);
                var categoryCandHolder = gAnlysDict.categories[category];
                if (isPolymorphicWord)
                {
                    foreach (var morhpeme in contentMorphemes)
                    {
                        preparer.AddWordCandidate(morhpeme, analyzer, categoryCandHolder);
                    }
                }
                else
                {
                    categoryCandHolder.candidates.Add(analyzer);
                }
            }
            ;
            foreach (var name in names)
            {
                gAnlysDict.dict[name] = analyzer;
            }
            ;
        }