1 | // matches first condition, leaves rest in MatchedRule |
2 | static L<RuleEngine2_MatchedRule> ai_ruleEngine2_rulesForInput_5(RuleEngine2 engine, SS inputsByType, O... _) { |
3 | bool debug = boolPar debug(_); |
4 | new L<RuleEngine2_MatchedRule> l; |
5 | |
6 | for (RuleEngine2.Rule rule : engine.rules) { |
7 | if (rule cast RuleEngine2.SimplifyWithRule) { |
8 | if (rule.isSplitRule) continue; |
9 | |
10 | // run simplifier |
11 | |
12 | S in = inputsByType.get('standard); |
13 | O f = rule.function(); |
14 | if (debug) print("Running simplifier " + rule.globalID + ": " + f); |
15 | O arg = rule.callOnTree ? optPar tree(_) : in; |
16 | if (arg == null) continue; |
17 | O result = f instanceof S |
18 | ? arg instanceof S ? callF(engine.callFunctionOnString, (S) f, arg) |
19 | : callAndMake((S) f, arg) |
20 | : callF(f, arg); |
21 | if (result == null) continue; |
22 | LS list = result instanceof Collection ? allToString((Collection) result) : ll(str(result)); |
23 | if (debug) print("Simplifier returned: " + list); |
24 | theLoop: for (S x : list) { |
25 | if (nempty(x) && neq(x, in)) { |
26 | final new RuleEngine2_MatchedRule matched; |
27 | matched.rule = rule; |
28 | matched.out = x; |
29 | matched.inputsByType = inputsByType; |
30 | |
31 | // call massagers in some dummy way |
32 | // (e.g. for humanOnly test) |
33 | |
34 | for (O massager : unnull(matched.rule.mapMassagers)) |
35 | if (callF(massager, new HashMap, null, null, matched) == null) { |
36 | if (debug) print("mapMassager returned null: " + massager); |
37 | continue theLoop; |
38 | } |
39 | |
40 | l.add(matched); |
41 | } |
42 | } |
43 | continue; |
44 | } |
45 | |
46 | // run normal rule |
47 | |
48 | final new RuleEngine2_MatchedRule matched; |
49 | matched.rule = rule; |
50 | matched.inputsByType = inputsByType; |
51 | matched.map = ciMap(); |
52 | matched.tokenizationFunction = or(matchAny_firstGroup("tokenize with *", rule.comments), f javaTokNPunctuationWithBrackets); |
53 | matched.outTokenizer = matchAny_firstGroup("tokenize out with *", rule.comments); |
54 | |
55 | if (!ai_ruleEngine2_matchStep(matched, inputsByType, true, _)) continue; |
56 | l.add(matched); |
57 | } |
58 | ret l; |
59 | } |
Began life as a copy of #1021489
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: | #1021498 |
Snippet name: | ai_ruleEngine2_rulesForInput_5 [with line types] |
Eternal ID of this version: | #1021498/28 |
Text MD5: | ca2e2491ecbf081840b1e12a0550f223 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-03-11 16:39:42 |
Source code size: | 2226 bytes / 59 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 424 / 481 |
Version history: | 27 change(s) |
Referenced in: | [show references] |