Fix a small bug
Tests results in Ibcd6c110f1d5582425f9592c42e31152131ef80c Bug: 7226877 Change-Id: I8d03bae3264974eff7b790e27c073b0a8758d17amain
parent
6d25be9ac5
commit
c9688ef267
|
@ -66,6 +66,7 @@ class BinaryFormat {
|
||||||
static int detectFormat(const uint8_t *const dict);
|
static int detectFormat(const uint8_t *const dict);
|
||||||
static int getHeaderSize(const uint8_t *const dict);
|
static int getHeaderSize(const uint8_t *const dict);
|
||||||
static int getFlags(const uint8_t *const dict);
|
static int getFlags(const uint8_t *const dict);
|
||||||
|
static bool hasBlacklistedOrNotAWordFlag(const int flags);
|
||||||
static void readHeaderValue(const uint8_t *const dict, const char *const key, int *outValue,
|
static void readHeaderValue(const uint8_t *const dict, const char *const key, int *outValue,
|
||||||
const int outValueSize);
|
const int outValueSize);
|
||||||
static int readHeaderValueInt(const uint8_t *const dict, const char *const key);
|
static int readHeaderValueInt(const uint8_t *const dict, const char *const key);
|
||||||
|
@ -162,6 +163,10 @@ inline int BinaryFormat::getFlags(const uint8_t *const dict) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool BinaryFormat::hasBlacklistedOrNotAWordFlag(const int flags) {
|
||||||
|
return flags & (FLAG_IS_BLACKLISTED | FLAG_IS_NOT_A_WORD);
|
||||||
|
}
|
||||||
|
|
||||||
inline int BinaryFormat::getHeaderSize(const uint8_t *const dict) {
|
inline int BinaryFormat::getHeaderSize(const uint8_t *const dict) {
|
||||||
switch (detectFormat(dict)) {
|
switch (detectFormat(dict)) {
|
||||||
case 1:
|
case 1:
|
||||||
|
|
|
@ -210,8 +210,7 @@ class DicNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isImpossibleBigramWord() const {
|
bool isImpossibleBigramWord() const {
|
||||||
const int probability = mDicNodeProperties.getProbability();
|
if (mDicNodeProperties.hasBlacklistedOrNotAWordFlag()) {
|
||||||
if (probability == 0) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const int prevWordLen = mDicNodeState.mDicNodeStatePrevWord.getPrevWordLength()
|
const int prevWordLen = mDicNodeState.mDicNodeStatePrevWord.getPrevWordLength()
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "binary_format.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
@ -144,6 +145,10 @@ class DicNodeProperties {
|
||||||
return mChildrenCount > 0 || mDepth != mLeavingDepth;
|
return mChildrenCount > 0 || mDepth != mLeavingDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasBlacklistedOrNotAWordFlag() const {
|
||||||
|
return BinaryFormat::hasBlacklistedOrNotAWordFlag(mFlags);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Caution!!!
|
// Caution!!!
|
||||||
// Use a default copy constructor and an assign operator because shallow copies are ok
|
// Use a default copy constructor and an assign operator because shallow copies are ok
|
||||||
|
|
|
@ -72,7 +72,7 @@ class TerminalAttributes {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isBlacklistedOrNotAWord() const {
|
bool isBlacklistedOrNotAWord() const {
|
||||||
return mFlags & (BinaryFormat::FLAG_IS_BLACKLISTED | BinaryFormat::FLAG_IS_NOT_A_WORD);
|
return BinaryFormat::hasBlacklistedOrNotAWordFlag(mFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue