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)

static new ThreadLocal<Double> web_matchAllPerms_partial_score;

static Map<WebNode> web_matchAllPerms_partial(Web patternWeb, Web inputWeb) {
  ret web_matchAllPerms_partial(patternWeb, inputWeb, 0);
}

static Map<WebNode> web_matchAllPerms_partial(Web patternWeb, Web inputWeb, double minScore) {
  L<WebNode> patternNodes = web_nodes(patternWeb);
  L<WebNode> inputNodes = web_nodes(inputWeb);
  if (l(patternNodes) > l(inputNodes))
    null;

  new Best<L<WebNode>> best;
  LL<WebNode> subsets = allSubsetsOfLength(l(patternNodes), inputNodes);
  for (L<WebNode> subset : subsets) {
    LL<WebNode> perms = allPermutations(subset);
    for (L<WebNode> perm : perms)
      best.put(perm, web_matchNodeLists(patternNodes, perm));
  }
  
  L<WebNode> l = isNaN(minScore) ? best! : best.getIfScoreAbove(minScore);
  web_matchAllPerms_partial_score.set(best.score());
  ret l == null ? null : twoListsToOrderedMap(patternNodes, l);
}

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: 346 / 388
Version history: 7 change(s)
Referenced in: [show references]