Beispiel #1
0
        public RootGBlockConverter()
        {
            var convList = new List <GBlockConverter>();

            mainConverter.converters = convList;
            replacer.number          = new Dictionary <string, GrammarBlock>();
            replacer.number.Add("one", new MinimumGBUnit {
                word = "1"
            });
            replacer.number.Add("two", new MinimumGBUnit {
                word = "2"
            });
            replacer.number.Add("three", new MinimumGBUnit {
                word = "3"
            });
            pronouc.dict = new Dictionary <string, MutableGrammarBlock>();
            convList.Add(replacer);
            convList.Add(pronouc);
            convList.Add(activizer);
            convList.Add(eachConv);
            convList.Add(defaultConv);
            MutableGrammarUnit subj = new StdMutableGUnit {
                word = "player"
            };

            subj.AddMetaInfo(StdMetaInfos.nominalBlock);
            activizer.defaultSubject = subj;
        }
Beispiel #2
0
 GBlockConvertResult GBlockConverter.ConvertGBlock(GrammarBlock sourceGBlock, GBlockConvertListener listener)
 {
     if (sourceGBlock.cluster != null)
     {
         var newClusterGB = new StdMutableClusterGBlock();
         foreach (var subGB in sourceGBlock.cluster.blocks)
         {
             var convertedSub = listener.subBlockConverter.ConvertGBlock(subGB, listener).result;
             if (convertedSub != null)
             {
                 newClusterGB.subBlocks.Add(convertedSub);
             }
         }
         GBlockConvertUtility.ApplyModAndMeta(newClusterGB, sourceGBlock, listener);
         return(new GBlockConvertResult(true, newClusterGB));
     }
     else if (sourceGBlock.unit != null)
     {
         var newGUnit = new StdMutableGUnit {
             word = sourceGBlock.unit.word
         };
         GBlockConvertUtility.ApplyModAndMeta(newGUnit, sourceGBlock, listener);
         return(new GBlockConvertResult(true, newGUnit));
     }
     return(default(GBlockConvertResult));
 }
Beispiel #3
0
        GBlockConvertResult GBlockConverter.ConvertGBlock(GrammarBlock sourceGBlock, GBlockConvertListener listener)
        {
            if (!GrammarBlockUtils.IsUnit(sourceGBlock, "each"))
            {
                return(default(GBlockConvertResult));
            }
            if (!GrammarBlockUtils.IsUnit(sourceGBlock.modifier, "turn"))
            {
                return(default(GBlockConvertResult));
            }
            var newSubject = listener.subBlockConverter.ConvertGBlock(sourceGBlock.modifier, listener).result;
            var newVerb    = new StdMutableGUnit {
                word = "begin"
            };

            (newVerb as MutableGrammarBlock).AddMetaInfo(StdMetaInfos.verbalBlock);
            MutableClusterGrammarBlock newSV = new StdMutableClusterGBlock();

            newSV.AddBlock(newSubject);
            newSV.AddBlock(newVerb);
            newSV.AddMetaInfo(StdMetaInfos.conditionSV);
            return(new GBlockConvertResult(true, newSV));
        }