Beispiel #1
0
        float TimeExpresssionToFloatSec(GrammarBlock timeExpression)
        {
            var vis = new TimeCountVisitor();

            GrammarBlockUtils.VisitGrammarBlock(timeExpression, vis);
            return(vis.result);
        }
Beispiel #2
0
 void GrammarBlockVisitor.IfClusterGrammarBlock(ClusterGrammarBlock cluster)
 {
     foreach (var block in cluster.blocks)
     {
         GrammarBlockUtils.VisitGrammarBlock(block, this);
     }
 }
Beispiel #3
0
        AttributeMatchResult AttributeMatcher.MatchAttribue(GrammarBlock attribute)
        {
            var checker = new MultiMatchingGBlockVisitor {
                candidates = candidates
            };

            GrammarBlockUtils.VisitGrammarBlock(attribute, checker);
            if (checker.hasOne && !checker.hasUnmatch)
            {
                return(AttributeMatchResult.POSITIVE);
            }
            return(AttributeMatchResult.NEGATIVE);
        }
Beispiel #4
0
 void BehaviorAnalyzer.AnalyzeBehavior(GrammarBlock behaviorExpressionByGBlock, Taker <BehaviorTriggerSet> listener)
 {
     //ensure behaver
     {
         var metaDepVis = new MetaInfoDependentGrammarBlockVisitor {
             doDeepSeek = true, doDeepSeekModifier = true
         };
         metaDepVis.metaToVis[StdMetaInfos.nominalBlock.word] = new EnsureBehaver {
             behaverGiver = stdGiver
         };
         GrammarBlockUtils.VisitGrammarBlock(behaviorExpressionByGBlock, metaDepVis);
     }
     //cereate behavior trigger
     {
         var rootTrigger    = new StdCompositeBehaviorTrigger();
         var namedCBTrigger = new Dictionary <string, CompositeBehaviorTrigger>();
         var processor      = new SentenceBlockRecursiveProcessor {
             subSentenceBehaviorTaker = rootTrigger, behaverSetCheck = bSetCheck, namedCBTriggers = namedCBTrigger, support = new StdBehaviorReadySupport {
                 assetMediator = assetMediator.assetMed
             }
         };
         processor.GrammarBlockCommon(behaviorExpressionByGBlock);
         if (rootTrigger.bTriggers.Count > 0 || namedCBTrigger.Count > 0)
         {
             List <NameAndBTrigger> namedTriggers = null;
             if (namedCBTrigger.Count > 0)
             {
                 namedTriggers = new List <NameAndBTrigger>();
                 foreach (var pair in namedCBTrigger)
                 {
                     namedTriggers.Add(new NameAndBTrigger {
                         name = pair.Key, bTrigger = pair.Value
                     });
                 }
             }
             var result = new BehaviorTriggerSet {
                 rootTrigger = rootTrigger.bTriggers.Count > 0 ? rootTrigger : null, namedTriggers = namedTriggers
             };
             listener.Take(result);
         }
     }
 }
Beispiel #5
0
 void GrammarBlockVisitor.IfGrammarUnit(GrammarUnit gUnit)
 {
     if (gUnit.modifier != null)
     {
         GBlockVisitor_GetFloat numberFetcher = new GBlockVisitor_GetFloat();
         if (string.Compare(gUnit.word, "hour", true) == 0)
         {
             GrammarBlockUtils.VisitGrammarBlock(gUnit.modifier, numberFetcher);
             result += numberFetcher.numberFloat * 60 * 60;
         }
         else if (string.Compare(gUnit.word, "minute", true) == 0)
         {
             GrammarBlockUtils.VisitGrammarBlock(gUnit.modifier, numberFetcher);
             result += numberFetcher.numberFloat * 60;
         }
         else if (string.Compare(gUnit.word, "second", true) == 0)
         {
             GrammarBlockUtils.VisitGrammarBlock(gUnit.modifier, numberFetcher);
             result += numberFetcher.numberFloat;
         }
     }
 }