Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

24
LINES

< > BotCompany Repo | #1010467 // web_matchAllPerms_partial - pattern may be subnet of input

JavaX fragment (include)

1  
static new ThreadLocal<Double> web_matchAllPerms_partial_score;
2  
3  
static Map<WebNode> web_matchAllPerms_partial(Web patternWeb, Web inputWeb) {
4  
  ret web_matchAllPerms_partial(patternWeb, inputWeb, 0);
5  
}
6  
7  
static Map<WebNode> web_matchAllPerms_partial(Web patternWeb, Web inputWeb, double minScore) {
8  
  L<WebNode> patternNodes = web_nodes(patternWeb);
9  
  L<WebNode> inputNodes = web_nodes(inputWeb);
10  
  if (l(patternNodes) > l(inputNodes))
11  
    null;
12  
13  
  new Best<L<WebNode>> best;
14  
  LL<WebNode> subsets = allSubsetsOfLength(l(patternNodes), inputNodes);
15  
  for (L<WebNode> subset : subsets) {
16  
    LL<WebNode> perms = allPermutations(subset);
17  
    for (L<WebNode> perm : perms)
18  
      best.put(perm, web_matchNodeLists(patternNodes, perm));
19  
  }
20  
  
21  
  L<WebNode> l = isNaN(minScore) ? best! : best.getIfScoreAbove(minScore);
22  
  web_matchAllPerms_partial_score.set(best.score());
23  
  ret l == null ? null : twoListsToOrderedMap(patternNodes, l);
24  
}

Author comment

Began life as a copy of #1010329

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1010467
Snippet name: web_matchAllPerms_partial - pattern may be subnet of input
Eternal ID of this version: #1010467/8
Text MD5: e8c1349b3b1616da167be5fd7b9fb175
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-09-22 18:02:42
Source code size: 955 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 352 / 394
Version history: 7 change(s)
Referenced in: [show references]