Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
e6715e32
Commit
e6715e32
authored
13 years ago
by
Jean Chalard
Browse files
Options
Downloads
Patches
Plain Diff
Move a function out of a #endif to reduce a future commit
Change-Id: Ic8f3160a96b6d79ba19ff9c8eda1692e94a38e98
parent
b67d5e91
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
native/src/unigram_dictionary.cpp
+41
-83
41 additions, 83 deletions
native/src/unigram_dictionary.cpp
with
41 additions
and
83 deletions
native/src/unigram_dictionary.cpp
+
41
−
83
View file @
e6715e32
...
@@ -674,6 +674,47 @@ inline void UnigramDictionary::onTerminal(unsigned short int* word, const int de
...
@@ -674,6 +674,47 @@ inline void UnigramDictionary::onTerminal(unsigned short int* word, const int de
}
}
}
}
bool
UnigramDictionary
::
getSplitTwoWordsSuggestion
(
const
int
inputLength
,
const
int
firstWordStartPos
,
const
int
firstWordLength
,
const
int
secondWordStartPos
,
const
int
secondWordLength
,
const
bool
isSpaceProximity
)
{
if
(
inputLength
>=
MAX_WORD_LENGTH
)
return
false
;
if
(
0
>=
firstWordLength
||
0
>=
secondWordLength
||
firstWordStartPos
>=
secondWordStartPos
||
firstWordStartPos
<
0
||
secondWordStartPos
+
secondWordLength
>
inputLength
)
return
false
;
const
int
newWordLength
=
firstWordLength
+
secondWordLength
+
1
;
// Allocating variable length array on stack
unsigned
short
word
[
newWordLength
];
const
int
firstFreq
=
getMostFrequentWordLike
(
firstWordStartPos
,
firstWordLength
,
mWord
);
if
(
DEBUG_DICT
)
{
LOGI
(
"First freq: %d"
,
firstFreq
);
}
if
(
firstFreq
<=
0
)
return
false
;
for
(
int
i
=
0
;
i
<
firstWordLength
;
++
i
)
{
word
[
i
]
=
mWord
[
i
];
}
const
int
secondFreq
=
getMostFrequentWordLike
(
secondWordStartPos
,
secondWordLength
,
mWord
);
if
(
DEBUG_DICT
)
{
LOGI
(
"Second freq: %d"
,
secondFreq
);
}
if
(
secondFreq
<=
0
)
return
false
;
word
[
firstWordLength
]
=
SPACE
;
for
(
int
i
=
(
firstWordLength
+
1
);
i
<
newWordLength
;
++
i
)
{
word
[
i
]
=
mWord
[
i
-
firstWordLength
-
1
];
}
int
pairFreq
=
calcFreqForSplitTwoWords
(
TYPED_LETTER_MULTIPLIER
,
firstWordLength
,
secondWordLength
,
firstFreq
,
secondFreq
,
isSpaceProximity
);
if
(
DEBUG_DICT
)
{
LOGI
(
"Split two words: %d, %d, %d, %d, %d"
,
firstFreq
,
secondFreq
,
pairFreq
,
inputLength
,
TYPED_LETTER_MULTIPLIER
);
}
addWord
(
word
,
newWordLength
,
pairFreq
);
return
true
;
}
#ifndef NEW_DICTIONARY_FORMAT
#ifndef NEW_DICTIONARY_FORMAT
// TODO: Don't forget to bring inline functions back to over where they are used.
// TODO: Don't forget to bring inline functions back to over where they are used.
...
@@ -854,49 +895,7 @@ int UnigramDictionary::getBigramPosition(int pos, unsigned short *word, int offs
...
@@ -854,49 +895,7 @@ int UnigramDictionary::getBigramPosition(int pos, unsigned short *word, int offs
return
NOT_VALID_WORD
;
return
NOT_VALID_WORD
;
}
}
// The following functions will be modified.
// The following functions will be modified.
bool
UnigramDictionary
::
getSplitTwoWordsSuggestion
(
const
int
inputLength
,
const
int
firstWordStartPos
,
const
int
firstWordLength
,
const
int
secondWordStartPos
,
const
int
secondWordLength
,
const
bool
isSpaceProximity
)
{
if
(
inputLength
>=
MAX_WORD_LENGTH
)
return
false
;
if
(
0
>=
firstWordLength
||
0
>=
secondWordLength
||
firstWordStartPos
>=
secondWordStartPos
||
firstWordStartPos
<
0
||
secondWordStartPos
+
secondWordLength
>
inputLength
)
return
false
;
const
int
newWordLength
=
firstWordLength
+
secondWordLength
+
1
;
// Allocating variable length array on stack
unsigned
short
word
[
newWordLength
];
const
int
firstFreq
=
getMostFrequentWordLike
(
firstWordStartPos
,
firstWordLength
,
mWord
);
if
(
DEBUG_DICT
)
{
LOGI
(
"First freq: %d"
,
firstFreq
);
}
if
(
firstFreq
<=
0
)
return
false
;
for
(
int
i
=
0
;
i
<
firstWordLength
;
++
i
)
{
word
[
i
]
=
mWord
[
i
];
}
const
int
secondFreq
=
getMostFrequentWordLike
(
secondWordStartPos
,
secondWordLength
,
mWord
);
if
(
DEBUG_DICT
)
{
LOGI
(
"Second freq: %d"
,
secondFreq
);
}
if
(
secondFreq
<=
0
)
return
false
;
word
[
firstWordLength
]
=
SPACE
;
for
(
int
i
=
(
firstWordLength
+
1
);
i
<
newWordLength
;
++
i
)
{
word
[
i
]
=
mWord
[
i
-
firstWordLength
-
1
];
}
int
pairFreq
=
calcFreqForSplitTwoWords
(
TYPED_LETTER_MULTIPLIER
,
firstWordLength
,
secondWordLength
,
firstFreq
,
secondFreq
,
isSpaceProximity
);
if
(
DEBUG_DICT
)
{
LOGI
(
"Split two words: %d, %d, %d, %d, %d"
,
firstFreq
,
secondFreq
,
pairFreq
,
inputLength
,
TYPED_LETTER_MULTIPLIER
);
}
addWord
(
word
,
newWordLength
,
pairFreq
);
return
true
;
}
inline
bool
UnigramDictionary
::
processCurrentNode
(
const
int
initialPos
,
const
int
initialDepth
,
inline
bool
UnigramDictionary
::
processCurrentNode
(
const
int
initialPos
,
const
int
initialDepth
,
const
int
maxDepth
,
const
bool
initialTraverseAllNodes
,
int
matchWeight
,
int
inputIndex
,
const
int
maxDepth
,
const
bool
initialTraverseAllNodes
,
int
matchWeight
,
int
inputIndex
,
const
int
initialDiffs
,
const
int
skipPos
,
const
int
excessivePos
,
const
int
transposedPos
,
const
int
initialDiffs
,
const
int
skipPos
,
const
int
excessivePos
,
const
int
transposedPos
,
...
@@ -992,47 +991,6 @@ inline bool UnigramDictionary::processCurrentNode(const int initialPos, const in
...
@@ -992,47 +991,6 @@ inline bool UnigramDictionary::processCurrentNode(const int initialPos, const in
#else // NEW_DICTIONARY_FORMAT
#else // NEW_DICTIONARY_FORMAT
bool
UnigramDictionary
::
getSplitTwoWordsSuggestion
(
const
int
inputLength
,
const
int
firstWordStartPos
,
const
int
firstWordLength
,
const
int
secondWordStartPos
,
const
int
secondWordLength
,
const
bool
isSpaceProximity
)
{
if
(
inputLength
>=
MAX_WORD_LENGTH
)
return
false
;
if
(
0
>=
firstWordLength
||
0
>=
secondWordLength
||
firstWordStartPos
>=
secondWordStartPos
||
firstWordStartPos
<
0
||
secondWordStartPos
+
secondWordLength
>
inputLength
)
return
false
;
const
int
newWordLength
=
firstWordLength
+
secondWordLength
+
1
;
// Allocating variable length array on stack
unsigned
short
word
[
newWordLength
];
const
int
firstFreq
=
getMostFrequentWordLike
(
firstWordStartPos
,
firstWordLength
,
mWord
);
if
(
DEBUG_DICT
)
{
LOGI
(
"First freq: %d"
,
firstFreq
);
}
if
(
firstFreq
<=
0
)
return
false
;
for
(
int
i
=
0
;
i
<
firstWordLength
;
++
i
)
{
word
[
i
]
=
mWord
[
i
];
}
const
int
secondFreq
=
getMostFrequentWordLike
(
secondWordStartPos
,
secondWordLength
,
mWord
);
if
(
DEBUG_DICT
)
{
LOGI
(
"Second freq: %d"
,
secondFreq
);
}
if
(
secondFreq
<=
0
)
return
false
;
word
[
firstWordLength
]
=
SPACE
;
for
(
int
i
=
(
firstWordLength
+
1
);
i
<
newWordLength
;
++
i
)
{
word
[
i
]
=
mWord
[
i
-
firstWordLength
-
1
];
}
int
pairFreq
=
calcFreqForSplitTwoWords
(
TYPED_LETTER_MULTIPLIER
,
firstWordLength
,
secondWordLength
,
firstFreq
,
secondFreq
,
isSpaceProximity
);
if
(
DEBUG_DICT
)
{
LOGI
(
"Split two words: %d, %d, %d, %d, %d"
,
firstFreq
,
secondFreq
,
pairFreq
,
inputLength
,
TYPED_LETTER_MULTIPLIER
);
}
addWord
(
word
,
newWordLength
,
pairFreq
);
return
true
;
}
inline
bool
UnigramDictionary
::
processCurrentNode
(
const
int
initialPos
,
const
int
initialDepth
,
inline
bool
UnigramDictionary
::
processCurrentNode
(
const
int
initialPos
,
const
int
initialDepth
,
const
int
maxDepth
,
const
bool
initialTraverseAllNodes
,
int
matchWeight
,
int
inputIndex
,
const
int
maxDepth
,
const
bool
initialTraverseAllNodes
,
int
matchWeight
,
int
inputIndex
,
const
int
initialDiffs
,
const
int
skipPos
,
const
int
excessivePos
,
const
int
transposedPos
,
const
int
initialDiffs
,
const
int
skipPos
,
const
int
excessivePos
,
const
int
transposedPos
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment