1 | // matches first condition, leaves rest in MatchedRule |
2 | static L<RuleEngine2_MatchedRule> ai_ruleEngine2_rulesForInput_4(RuleEngine2 engine, SS inputsByType) { |
3 | new L<RuleEngine2_MatchedRule> l; |
4 | for (RuleEngine2.Rule rule : engine.rules) { |
5 | TextAndType in = first(rule.insWithType); |
6 | S cond = in.text; |
7 | S tokenize = or(matchAny_firstGroup("tokenize with *", rule.comments), f javaTokNPunctuationWithBrackets); |
8 | LS tokC = (LS) callAndMake(tokenize, cond); |
9 | S input = inputsByType.get(in.type); |
10 | if (input == null) continue; |
11 | LS tokI = (LS) callAndMake(tokenize, input); |
12 | tokI = ai_applyWordSplitPattern1(tokC, tokI); |
13 | SS map = zipTwoListsToCIMap_strict_withoutEquals(tokC, tokI); |
14 | if (map == null) continue; |
15 | //print(map + " | " + cond + " | " + rule.vars); |
16 | final new RuleEngine2_MatchedRule matched; |
17 | matched.rule = rule; |
18 | matched.map = map; |
19 | matched.matchedLines.add(pair(tokC, tokI)); |
20 | matched.tokenizationFunction = tokenize; |
21 | matched.remainingConditions = nullIfEmpty(map(dropFirst(rule.in), func(S s) -> S { matched.applyMappingTo(s) })); |
22 | matched.remainingConditionsWithType = nullIfEmpty(map(dropFirst(rule.insWithType), func(TextAndType in) -> TextAndType { TextAndType(matched.applyMappingTo(in.text), in.type) })); |
23 | Map<PairS, Int> qualities = ai_ruleEngine2_mappingQualities(rule); |
24 | for (S a, b : map) { |
25 | mapPut(matched.mappingQuality, a, qualities.get(pair(a, b))); |
26 | } |
27 | l.add(matched); |
28 | } |
29 | ret l; |
30 | } |
Began life as a copy of #1021405
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1021489 |
Snippet name: | ai_ruleEngine2_rulesForInput_4 [with line types] |
Eternal ID of this version: | #1021489/7 |
Text MD5: | f64a4cae13cfc332d30176c1051a0750 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-02-15 06:09:20 |
Source code size: | 1515 bytes / 30 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 317 / 336 |
Version history: | 6 change(s) |
Referenced in: | [show references] |