Clean up macro variables

Change-Id: I0d9983c1a766b97182953328fa45f488e110bc01
main
Ken Wakasa 2013-06-04 15:40:30 +09:00
parent 0dbae77496
commit 11dc3a371d
4 changed files with 58 additions and 34 deletions

View File

@ -287,25 +287,6 @@ static inline void prof_out(void) {
#define SUGGEST_MULTIPLE_WORDS true #define SUGGEST_MULTIPLE_WORDS true
#define SUGGEST_INTERFACE_OUTPUT_SCALE 1000000.0f #define SUGGEST_INTERFACE_OUTPUT_SCALE 1000000.0f
// The following "rate"s are used as a multiplier before dividing by 100, so they are in percent.
#define WORDS_WITH_MISSING_CHARACTER_DEMOTION_RATE 80
#define WORDS_WITH_MISSING_CHARACTER_DEMOTION_START_POS_10X 12
#define WORDS_WITH_MISSING_SPACE_CHARACTER_DEMOTION_RATE 58
#define WORDS_WITH_MISTYPED_SPACE_DEMOTION_RATE 50
#define WORDS_WITH_EXCESSIVE_CHARACTER_DEMOTION_RATE 75
#define WORDS_WITH_EXCESSIVE_CHARACTER_OUT_OF_PROXIMITY_DEMOTION_RATE 75
#define WORDS_WITH_TRANSPOSED_CHARACTERS_DEMOTION_RATE 70
#define FULL_MATCHED_WORDS_PROMOTION_RATE 120
#define WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE 90
#define WORDS_WITH_ADDITIONAL_PROXIMITY_CHARACTER_DEMOTION_RATE 70
#define WORDS_WITH_MATCH_SKIP_PROMOTION_RATE 105
#define WORDS_WITH_JUST_ONE_CORRECTION_PROMOTION_RATE 148
#define WORDS_WITH_JUST_ONE_CORRECTION_PROMOTION_MULTIPLIER 3
#define CORRECTION_COUNT_RATE_DEMOTION_RATE_BASE 45
#define INPUT_EXCEEDS_OUTPUT_DEMOTION_RATE 70
#define FIRST_CHAR_DIFFERENT_DEMOTION_RATE 96
#define TWO_WORDS_CAPITALIZED_DEMOTION_RATE 50
#define TWO_WORDS_CORRECTION_DEMOTION_BASE 80
#define ZERO_DISTANCE_PROMOTION_RATE 110.0f #define ZERO_DISTANCE_PROMOTION_RATE 110.0f
#define NEUTRAL_SCORE_SQUARED_RADIUS 8.0f #define NEUTRAL_SCORE_SQUARED_RADIUS 8.0f
#define HALF_SCORE_SQUARED_RADIUS 32.0f #define HALF_SCORE_SQUARED_RADIUS 32.0f
@ -330,6 +311,13 @@ static inline void prof_out(void) {
#define MAX_POINTER_COUNT 1 #define MAX_POINTER_COUNT 1
#define MAX_POINTER_COUNT_G 2 #define MAX_POINTER_COUNT_G 2
// Queue IDs and size for DicNodesCache
#define DIC_NODES_CACHE_INITIAL_QUEUE_ID_ACTIVE 0
#define DIC_NODES_CACHE_INITIAL_QUEUE_ID_NEXT_ACTIVE 1
#define DIC_NODES_CACHE_INITIAL_QUEUE_ID_TERMINAL 2
#define DIC_NODES_CACHE_INITIAL_QUEUE_ID_CACHE_FOR_CONTINUOUS_SUGGESTION 3
#define DIC_NODES_CACHE_PRIORITY_QUEUES_SIZE 4
// Size, in bytes, of the bloom filter index for bigrams // Size, in bytes, of the bloom filter index for bigrams
// 128 gives us 1024 buckets. The probability of false positive is (1 - e ** (-kn/m))**k, // 128 gives us 1024 buckets. The probability of false positive is (1 - e ** (-kn/m))**k,
// where k is the number of hash functions, n the number of bigrams, and m the number of // where k is the number of hash functions, n the number of bigrams, and m the number of

View File

@ -30,6 +30,27 @@ namespace latinime {
class ProximityInfo; class ProximityInfo;
// private static const member variables
// The following "rate"s are used as a multiplier before dividing by 100, so they are in percent.
const int Correction::WORDS_WITH_MISSING_CHARACTER_DEMOTION_RATE = 80;
const int Correction::WORDS_WITH_MISSING_CHARACTER_DEMOTION_START_POS_10X = 12;
const int Correction::WORDS_WITH_MISSING_SPACE_CHARACTER_DEMOTION_RATE = 58;
const int Correction::WORDS_WITH_MISTYPED_SPACE_DEMOTION_RATE = 50;
const int Correction::WORDS_WITH_EXCESSIVE_CHARACTER_DEMOTION_RATE = 75;
const int Correction::WORDS_WITH_EXCESSIVE_CHARACTER_OUT_OF_PROXIMITY_DEMOTION_RATE = 75;
const int Correction::WORDS_WITH_TRANSPOSED_CHARACTERS_DEMOTION_RATE = 70;
const int Correction::FULL_MATCHED_WORDS_PROMOTION_RATE = 120;
const int Correction::WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE = 90;
const int Correction::WORDS_WITH_ADDITIONAL_PROXIMITY_CHARACTER_DEMOTION_RATE = 70;
const int Correction::WORDS_WITH_MATCH_SKIP_PROMOTION_RATE = 105;
const int Correction::WORDS_WITH_JUST_ONE_CORRECTION_PROMOTION_RATE = 148;
const int Correction::WORDS_WITH_JUST_ONE_CORRECTION_PROMOTION_MULTIPLIER = 3;
const int Correction::CORRECTION_COUNT_RATE_DEMOTION_RATE_BASE = 45;
const int Correction::INPUT_EXCEEDS_OUTPUT_DEMOTION_RATE = 70;
const int Correction::FIRST_CHAR_DIFFERENT_DEMOTION_RATE = 96;
const int Correction::TWO_WORDS_CAPITALIZED_DEMOTION_RATE = 50;
const int Correction::TWO_WORDS_CORRECTION_DEMOTION_BASE = 80;
///////////////////////////// /////////////////////////////
// edit distance funcitons // // edit distance funcitons //
///////////////////////////// /////////////////////////////

View File

@ -135,6 +135,27 @@ class Correction {
private: private:
DISALLOW_COPY_AND_ASSIGN(Correction); DISALLOW_COPY_AND_ASSIGN(Correction);
// The following "rate"s are used as a multiplier before dividing by 100, so they are in
// percent.
static const int WORDS_WITH_MISSING_CHARACTER_DEMOTION_RATE;
static const int WORDS_WITH_MISSING_CHARACTER_DEMOTION_START_POS_10X;
static const int WORDS_WITH_MISSING_SPACE_CHARACTER_DEMOTION_RATE;
static const int WORDS_WITH_MISTYPED_SPACE_DEMOTION_RATE;
static const int WORDS_WITH_EXCESSIVE_CHARACTER_DEMOTION_RATE;
static const int WORDS_WITH_EXCESSIVE_CHARACTER_OUT_OF_PROXIMITY_DEMOTION_RATE;
static const int WORDS_WITH_TRANSPOSED_CHARACTERS_DEMOTION_RATE;
static const int FULL_MATCHED_WORDS_PROMOTION_RATE;
static const int WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE;
static const int WORDS_WITH_ADDITIONAL_PROXIMITY_CHARACTER_DEMOTION_RATE;
static const int WORDS_WITH_MATCH_SKIP_PROMOTION_RATE;
static const int WORDS_WITH_JUST_ONE_CORRECTION_PROMOTION_RATE;
static const int WORDS_WITH_JUST_ONE_CORRECTION_PROMOTION_MULTIPLIER;
static const int CORRECTION_COUNT_RATE_DEMOTION_RATE_BASE;
static const int INPUT_EXCEEDS_OUTPUT_DEMOTION_RATE;
static const int FIRST_CHAR_DIFFERENT_DEMOTION_RATE;
static const int TWO_WORDS_CAPITALIZED_DEMOTION_RATE;
static const int TWO_WORDS_CORRECTION_DEMOTION_BASE;
///////////////////////// /////////////////////////
// static inline utils // // static inline utils //
///////////////////////// /////////////////////////

View File

@ -22,12 +22,6 @@
#include "defines.h" #include "defines.h"
#include "suggest/core/dicnode/dic_node_priority_queue.h" #include "suggest/core/dicnode/dic_node_priority_queue.h"
#define INITIAL_QUEUE_ID_ACTIVE 0
#define INITIAL_QUEUE_ID_NEXT_ACTIVE 1
#define INITIAL_QUEUE_ID_TERMINAL 2
#define INITIAL_QUEUE_ID_CACHE_FOR_CONTINUOUS_SUGGESTION 3
#define PRIORITY_QUEUES_SIZE 4
namespace latinime { namespace latinime {
class DicNode; class DicNode;
@ -38,11 +32,12 @@ class DicNode;
class DicNodesCache { class DicNodesCache {
public: public:
AK_FORCE_INLINE DicNodesCache() AK_FORCE_INLINE DicNodesCache()
: mActiveDicNodes(&mDicNodePriorityQueues[INITIAL_QUEUE_ID_ACTIVE]), : mActiveDicNodes(&mDicNodePriorityQueues[DIC_NODES_CACHE_INITIAL_QUEUE_ID_ACTIVE]),
mNextActiveDicNodes(&mDicNodePriorityQueues[INITIAL_QUEUE_ID_NEXT_ACTIVE]), mNextActiveDicNodes(&mDicNodePriorityQueues[
mTerminalDicNodes(&mDicNodePriorityQueues[INITIAL_QUEUE_ID_TERMINAL]), DIC_NODES_CACHE_INITIAL_QUEUE_ID_NEXT_ACTIVE]),
mCachedDicNodesForContinuousSuggestion( mTerminalDicNodes(&mDicNodePriorityQueues[DIC_NODES_CACHE_INITIAL_QUEUE_ID_TERMINAL]),
&mDicNodePriorityQueues[INITIAL_QUEUE_ID_CACHE_FOR_CONTINUOUS_SUGGESTION]), mCachedDicNodesForContinuousSuggestion(&mDicNodePriorityQueues[
DIC_NODES_CACHE_INITIAL_QUEUE_ID_CACHE_FOR_CONTINUOUS_SUGGESTION]),
mInputIndex(0), mLastCachedInputIndex(0) { mInputIndex(0), mLastCachedInputIndex(0) {
} }
@ -147,9 +142,8 @@ class DicNodesCache {
mCachedDicNodesForContinuousSuggestion->dump(); mCachedDicNodesForContinuousSuggestion->dump();
} }
mInputIndex = mLastCachedInputIndex; mInputIndex = mLastCachedInputIndex;
mCachedDicNodesForContinuousSuggestion = mCachedDicNodesForContinuousSuggestion = moveNodesAndReturnReusableEmptyQueue(
moveNodesAndReturnReusableEmptyQueue( mCachedDicNodesForContinuousSuggestion, &mActiveDicNodes);
mCachedDicNodesForContinuousSuggestion, &mActiveDicNodes);
} }
AK_FORCE_INLINE static DicNodePriorityQueue *moveNodesAndReturnReusableEmptyQueue( AK_FORCE_INLINE static DicNodePriorityQueue *moveNodesAndReturnReusableEmptyQueue(
@ -169,7 +163,7 @@ class DicNodesCache {
mTerminalDicNodes->clear(); mTerminalDicNodes->clear();
} }
DicNodePriorityQueue mDicNodePriorityQueues[PRIORITY_QUEUES_SIZE]; DicNodePriorityQueue mDicNodePriorityQueues[DIC_NODES_CACHE_PRIORITY_QUEUES_SIZE];
// Active dicNodes currently being expanded. // Active dicNodes currently being expanded.
DicNodePriorityQueue *mActiveDicNodes; DicNodePriorityQueue *mActiveDicNodes;
// Next dicNodes to be expanded. // Next dicNodes to be expanded.