Small performance tweak
Change-Id: Icd540742073d49d12e70b2d8bd99aaf7ccb5802d
This commit is contained in:
parent
e91f32d8c1
commit
d10c473347
2 changed files with 8 additions and 8 deletions
|
@ -199,20 +199,20 @@ public class UserHistoryForgettingCurveUtils {
|
||||||
public static final int[][] SCORE_TABLE = new int[FC_LEVEL_MAX][ELAPSED_TIME_MAX + 1];
|
public static final int[][] SCORE_TABLE = new int[FC_LEVEL_MAX][ELAPSED_TIME_MAX + 1];
|
||||||
static {
|
static {
|
||||||
for (int i = 0; i < FC_LEVEL_MAX; ++i) {
|
for (int i = 0; i < FC_LEVEL_MAX; ++i) {
|
||||||
final double initialFreq;
|
final float initialFreq;
|
||||||
if (i >= 2) {
|
if (i >= 2) {
|
||||||
initialFreq = FC_FREQ_MAX;
|
initialFreq = FC_FREQ_MAX;
|
||||||
} else if (i == 1) {
|
} else if (i == 1) {
|
||||||
initialFreq = (double)FC_FREQ_MAX / 2;
|
initialFreq = FC_FREQ_MAX / 2;
|
||||||
} else if (i == 0) {
|
} else if (i == 0) {
|
||||||
initialFreq = (double)FC_FREQ_MAX / 4;
|
initialFreq = FC_FREQ_MAX / 4;
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (int j = 0; j < ELAPSED_TIME_MAX; ++j) {
|
for (int j = 0; j < ELAPSED_TIME_MAX; ++j) {
|
||||||
final double elapsedHour = j * ELAPSED_TIME_INTERVAL_HOURS;
|
final float elapsedHours = j * ELAPSED_TIME_INTERVAL_HOURS;
|
||||||
final double freq =
|
final double freq =
|
||||||
initialFreq * Math.pow(initialFreq, elapsedHour / HALF_LIFE_HOURS);
|
initialFreq * Math.pow(initialFreq, elapsedHours / HALF_LIFE_HOURS);
|
||||||
final int intFreq = Math.min(FC_FREQ_MAX, Math.max(0, (int)freq));
|
final int intFreq = Math.min(FC_FREQ_MAX, Math.max(0, (int)freq));
|
||||||
SCORE_TABLE[i][j] = intFreq;
|
SCORE_TABLE[i][j] = intFreq;
|
||||||
}
|
}
|
||||||
|
|
|
@ -787,9 +787,9 @@ public class BinaryDictInputOutput {
|
||||||
// (discretizedFrequency + 0.5) times this value to get the median value of the step,
|
// (discretizedFrequency + 0.5) times this value to get the median value of the step,
|
||||||
// which is the best approximation. This is how we get the most precise result with
|
// which is the best approximation. This is how we get the most precise result with
|
||||||
// only four bits.
|
// only four bits.
|
||||||
final double stepSize =
|
final float stepSize =
|
||||||
(MAX_TERMINAL_FREQUENCY - unigramFrequency) / (1.5 + MAX_BIGRAM_FREQUENCY);
|
(MAX_TERMINAL_FREQUENCY - unigramFrequency) / (1.5f + MAX_BIGRAM_FREQUENCY);
|
||||||
final double firstStepStart = 1 + unigramFrequency + (stepSize / 2.0);
|
final float firstStepStart = 1 + unigramFrequency + (stepSize / 2.0f);
|
||||||
final int discretizedFrequency = (int)((bigramFrequency - firstStepStart) / stepSize);
|
final int discretizedFrequency = (int)((bigramFrequency - firstStepStart) / stepSize);
|
||||||
// If the bigram freq is less than half-a-step higher than the unigram freq, we get -1
|
// If the bigram freq is less than half-a-step higher than the unigram freq, we get -1
|
||||||
// here. The best approximation would be the unigram freq itself, so we should not
|
// here. The best approximation would be the unigram freq itself, so we should not
|
||||||
|
|
Loading…
Reference in a new issue