1 | scope ai_gazelle_analyzeStatementsForRule. |
2 | |
3 | sclass #Data { |
4 | MultiSet<S> statements; |
5 | |
6 | Set<S> possibleVars, usedVars, unusedVars, |
7 | varsUsedInGood, varsUsedInBad, |
8 | varsUsedInGoodOnly, varsUsedInBadOnly; |
9 | Set<S> unclearVars; // used in good and bad mappings |
10 | MultiMap<S> goodMappings, badMappings, // per var |
11 | alwaysGoodMappings, alwaysBadMappings; |
12 | L<SS> completeGoodMappings, completeBadMappings; |
13 | Map<PairS, PosNegScore> varScores; |
14 | } |
15 | |
16 | static Data ai_gazelle_analyzeStatementsForRule(Collection<S> l) { |
17 | Set<S> possibleVars = asCISet(matchAny_firstGroups("possible variable *", l)); |
18 | Set<S> usedVars = asCISet(matchX_any_firstGroups("... variable * was used", l)); |
19 | Set<S> unusedVars = asCISet(listMinusSet(possibleVars, usedVars)); |
20 | Set<S> varsUsedInGood = asCISet(matchX_any_firstGroups("in a good mapping, variable * was used", l)); |
21 | Set<S> varsUsedInBad = asCISet(matchX_any_firstGroups("in a bad mapping, variable * was used", l)); |
22 | Set<S> unclearVars = setIntersection(varsUsedInGood, varsUsedInBad); |
23 | MultiMap<S> goodMappings = uniquifyMultiMapValues(pairsToMultiMap(matchX_any_firstAndSecondGroups("in a good mapping, variable * was mapped to *", l))); |
24 | MultiMap<S> badMappings = uniquifyMultiMapValues(pairsToMultiMap(matchX_any_firstAndSecondGroups("in a bad mapping, variable * was mapped to *", l))); |
25 | MultiMap<S> alwaysGoodMappings = multiMapDiff(goodMappings, badMappings); |
26 | MultiMap<S> alwaysBadMappings = multiMapDiff(badMappings, goodMappings); |
27 | L<SS> completeGoodMappings = (L) map safeUnstruct(matchX_any_firstGroups("a good mapping is *", l)); |
28 | L<SS> completeBadMappings = (L) map safeUnstruct(matchX_any_firstGroups("a bad mapping is *", l)); |
29 | ret nu(Data, +possibleVars, +usedVars, +unusedVars, |
30 | +varsUsedInGood, +varsUsedInBad, +unclearVars, |
31 | varsUsedInGoodOnly := setDiff(varsUsedInGood, varsUsedInBad), |
32 | varsUsedInBadOnly := setDiff(varsUsedInBad, varsUsedInGood), |
33 | +goodMappings, +badMappings, |
34 | +alwaysGoodMappings, +alwaysBadMappings, |
35 | +completeGoodMappings, +completeBadMappings); |
36 | } |
37 | |
38 | end scope |
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, whxojlpjdney
No comments. add comment
Snippet ID: | #1021439 |
Snippet name: | ai_gazelle_analyzeStatementsForRule |
Eternal ID of this version: | #1021439/13 |
Text MD5: | 3695b9fe32664e22c247874ae4fd0ed2 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-29 21:42:44 |
Source code size: | 2105 bytes / 38 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 389 / 894 |
Version history: | 12 change(s) |
Referenced in: | [show references] |