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

50
LINES

< > BotCompany Repo | #1004873 // class Sucker [text prediction]

JavaX fragment (include)

1  
// all it needs is a text!
2  
sclass Sucker {
3  
  new HighestShortest highest;
4  
  /*new*/ ShortestPercentiles percentiles;
5  
  S text;
6  
  double lastScore;
7  
  bool changed;
8  
  int pivotLength;
9  
  
10  
  *() {}
11  
  *(S *text) {}
12  
  
13  
  // returns true when updated result
14  
  synchronized bool suck(S desc, Algorithm algorithm) {
15  
    print("Best score: " + highest.score);
16  
17  
    double score = scoreAlgorithm(algorithm, desc);
18  
    lastScore = score;
19  
    
20  
    bool change = false;
21  
    if (highest.update(desc, score)) change = true;
22  
    if (percentiles != null && percentiles.update(desc, score)) change = true;
23  
    if (change) changed = true;
24  
    ret change;
25  
  }
26  
  
27  
  S highestDesc() {
28  
    ret highest.a;
29  
  }
30  
  
31  
  double highestScore() {
32  
    ret highest.score;
33  
  }
34  
  
35  
  double scoreAlgorithm(Algorithm algorithm, S desc) {
36  
    ret scoreTextPredictAlgo(algorithm, getText(), l(desc), pivotLength);
37  
  }
38  
  
39  
  bool testLua(S luaCode) {
40  
    ret suck("L " + luaCode, makeLuaTextPredictAlgo("L " + luaCode));
41  
  }
42  
  
43  
  S getText() {
44  
    ret text;
45  
  }
46  
  
47  
  void reset() {
48  
    highest = new HighestShortest;
49  
  }
50  
}

Author comment

Began life as a copy of #1004698

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: #1004873
Snippet name: class Sucker [text prediction]
Eternal ID of this version: #1004873/1
Text MD5: 9c6dd0e461d537d8e42b4f679c51ce26
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-09-11 23:20:28
Source code size: 1128 bytes / 50 lines
Pitched / IR pitched: No / No
Views / Downloads: 474 / 706
Referenced in: [show references]