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

29
LINES

< > BotCompany Repo | #1010326 // web_matchNodeLists - returns match score (0 or negative); now case insensitve

JavaX fragment (include)

1  
static bool web_matchNodeLists_debug;
2  
3  
static int web_matchNodeLists(L<WebNode> l1, L<WebNode> l2) {
4  
  if (l(l1) != l(l2)) ret -1000;
5  
  int score = 0;
6  
  if (empty(l1)) ret score;
7  
  HashMap<WebNode> map = twoListsToHashMap(l1, l2);
8  
  Web web = first(l1).web, web2 = first(l2).web;
9  
  
10  
  // Score nodes
11  
  for i over l1: {
12  
    WebNode a = l1.get(i), b = l2.get(i);
13  
    if (web_isAnythingVariable(a)) continue;
14  
    //if (neq(web_labels(a), web_labels(b))) --score;
15  
    if (!containsAllIC_lisp(web_labels(b), web_labels(a))) --score;
16  
  }
17  
  
18  
  // Score relations
19  
  for (WebRelation rel : web_relationObjects(web)) {
20  
    WebNode aa = map.get(rel.a), bb = map.get(rel.b);
21  
    if (aa == null || bb == null) continue;
22  
    WebRelation rel2 = web2.getRelationOpt(aa, bb);
23  
    if (web_matchNodeLists_debug)
24  
      print("a=" + rel.a + ", b=" + rel.b + ", aa=" + aa + ", bb=" + bb + ", rel2 labels=" + (rel2 == null ? "-" : str(web_labels(rel2)) + ", labels=" + rel.labels);
25  
    if (rel2 == null || !containsAllIC_lisp(web_labels(rel2), web_labels(rel)))
26  
      --score;
27  
  }
28  
  ret score;
29  
}

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: #1010326
Snippet name: web_matchNodeLists - returns match score (0 or negative); now case insensitve
Eternal ID of this version: #1010326/12
Text MD5: 04b116069f1e281d8976d5a9854a8108
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-11-02 03:20:56
Source code size: 1100 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 400 / 434
Version history: 11 change(s)
Referenced in: [show references]