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)

// all it needs is a text!
sclass Sucker {
  new HighestShortest highest;
  /*new*/ ShortestPercentiles percentiles;
  S text;
  double lastScore;
  bool changed;
  int pivotLength;
  
  *() {}
  *(S *text) {}
  
  // returns true when updated result
  synchronized bool suck(S desc, Algorithm algorithm) {
    print("Best score: " + highest.score);

    double score = scoreAlgorithm(algorithm, desc);
    lastScore = score;
    
    bool change = false;
    if (highest.update(desc, score)) change = true;
    if (percentiles != null && percentiles.update(desc, score)) change = true;
    if (change) changed = true;
    ret change;
  }
  
  S highestDesc() {
    ret highest.a;
  }
  
  double highestScore() {
    ret highest.score;
  }
  
  double scoreAlgorithm(Algorithm algorithm, S desc) {
    ret scoreTextPredictAlgo(algorithm, getText(), l(desc), pivotLength);
  }
  
  bool testLua(S luaCode) {
    ret suck("L " + luaCode, makeLuaTextPredictAlgo("L " + luaCode));
  }
  
  S getText() {
    ret text;
  }
  
  void reset() {
    highest = new HighestShortest;
  }
}

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: 472 / 703
Referenced in: [show references]