Exemple #1
0
 public IEnumerable <LangToken> ProcessGroup(IEnumerable <LangToken> group, MLang lang)
 {
     foreach (var tagExport in TagExport)
     {
         var tag = new TokenTag
         {
             Key   = tagExport.Key,
             Value = tagExport.Value
         };
         foreach (var token in group)
         {
             token.Tags[tag.Key] = tag;
             tag.AddParent(token);
         }
     }
     foreach (var tagPriority in TagPriority)
     {
         foreach (var token in group)
         {
             if (token.Tags.TryGetValue(tagPriority.Key, out TokenTag tag))
             {
                 tag.Priority = tagPriority.Value;
             }
         }
     }
     if (Handlers.Count == 0)
     {
         foreach (var token in group)
         {
             yield return(token);
         }
     }
     else
     {
         var used = new HashSet <LangToken>();
         foreach (var handler in Handlers)
         {
             if (lang.TextProcessors.TryGetValue(handler, out ITokenProcessor processor))
             {
                 foreach (var r in processor.Process(group))
                 {
                     used.Add(r);
                 }
             }
         }
         foreach (var result in group)
         {
             if (used.Contains(result))
             {
                 yield return(result);
             }
         }
     }
 }
Exemple #2
0
        public IEnumerable <LangToken> Process(IEnumerable <LangToken> tokens)
        {
            foreach (var token in tokens)
            {
                if (long.TryParse(token.Value, out long x))
                {
                    var newTag = new TokenTag();
                    newTag.Key   = "integer";
                    newTag.Value = x.ToString();

                    token.Tags[newTag.Key] = newTag;
                    newTag.AddParent(token);
                    yield return(token);
                }
            }
        }
Exemple #3
0
        public IEnumerable <LangToken> Process(IEnumerable <LangToken> tokens)
        {
            Regex rgx = new Regex(@"^[a-zA-Z0-9]{5}$");

            foreach (var token in tokens)
            {
                if (rgx.IsMatch(token.Value))
                {
                    var tag = new TokenTag
                    {
                        Key   = "ticket",
                        Value = token.Value
                    };
                    token.Tags[tag.Key] = tag;
                    tag.AddParent(token);
                    yield return(token);
                }
            }
        }
Exemple #4
0
 public IEnumerable <LangToken> Process(IEnumerable <LangToken> tokens)
 {
     foreach (var token in tokens)
     {
         if (ModifiedTable.TryGetValue(token.Value, out Dictionary <string, string> dict))
         {
             foreach (var key in dict)
             {
                 if (key.Key == "value")
                 {
                     continue;
                 }
                 var tag = new TokenTag
                 {
                     Key   = key.Key,
                     Value = key.Value
                 };
                 token.Tags[tag.Key] = tag;
                 tag.AddParent(token);
             }
             yield return(token);
         }
     }
 }