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

18
LINES

< > BotCompany Repo | #1007544 // imSearch - Intelligence Machine search function

JavaX fragment (include)

1  
static L<AIConcept> imSearch(S query) {
2  
  query = trim(query);
3  
  new Matches m;
4  
  S qname = query, qcomment = query;
5  
  if (flexMatch("* [*]", query, m)) {
6  
    qname = $1;
7  
    qcomment = $2;
8  
  }
9  
  new Map<AIConcept, Int> scores;
10  
  for (AIConcept c : values(aiConceptsMap_cached())) {
11  
    int score = scoredSearch_score(c.name, qname)*2;
12  
    score += scoredSearch_score(c.comment, qcomment);
13  
    if (eqic(c.globalID, query)) score += 10;
14  
    if (score != 0)
15  
      scores.put(c, score);
16  
  }
17  
  ret keysSortedByValuesDesc(scores);
18  
}

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: #1007544
Snippet name: imSearch - Intelligence Machine search function
Eternal ID of this version: #1007544/7
Text MD5: 66b40c2ea804ae4dcec45e4b4511f269
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-29 16:52:17
Source code size: 544 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 525 / 526
Version history: 6 change(s)
Referenced in: [show references]