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
0f75be4a
Commit
0f75be4a
authored
11 years ago
by
Keisuke Kuroynagi
Committed by
Android (Google) Code Review
11 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Implement getCodePointsAndProbabilityAnd... for ver3 dicts."
parents
0f47d516
9601df5a
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/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp
+40
-3
40 additions, 3 deletions
...st/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp
with
40 additions
and
3 deletions
native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp
+
40
−
3
View file @
0f75be4a
...
...
@@ -14,7 +14,7 @@
* limitations under the License.
*/
#include
"suggest/policyimpl/dictionary/patricia_trie_policy.h"
#include
"suggest/policyimpl/dictionary/
dynamic_
patricia_trie_policy.h"
#include
"defines.h"
#include
"suggest/core/dicnode/dic_node.h"
...
...
@@ -62,8 +62,45 @@ int DynamicPatriciaTriePolicy::getCodePointsAndProbabilityAndReturnCodePointCoun
const
BinaryDictionaryInfo
*
const
binaryDictionaryInfo
,
const
int
nodePos
,
const
int
maxCodePointCount
,
int
*
const
outCodePoints
,
int
*
const
outUnigramProbability
)
const
{
// TODO: Implement.
return
0
;
// This method traverses parent nodes from the terminal by following parent pointers; thus,
// node code points are stored in the buffer in the reverse order.
int
reverseCodePoints
[
maxCodePointCount
];
int
mergedNodeCodePoints
[
maxCodePointCount
];
int
codePointCount
=
0
;
DynamicPatriciaTrieNodeReader
nodeReader
(
binaryDictionaryInfo
);
// First, read terminal node and get its probability.
nodeReader
.
fetchNodeInfoFromBufferAndGetNodeCodePoints
(
nodePos
,
maxCodePointCount
,
mergedNodeCodePoints
);
// Store terminal node probability.
*
outUnigramProbability
=
nodeReader
.
getProbability
();
// Store terminal node code points to buffer in the reverse order.
for
(
int
i
=
nodeReader
.
getCodePointCount
()
-
1
;
i
>=
0
;
--
i
)
{
reverseCodePoints
[
codePointCount
++
]
=
mergedNodeCodePoints
[
i
];
}
// Then, follow parent pos toward the root node.
while
(
nodeReader
.
getParentPos
()
!=
getRootPosition
())
{
// codePointCount must be incremented at least once in each iteration to ensure preventing
// infinite loop.
if
(
nodeReader
.
isDeleted
()
||
codePointCount
>
maxCodePointCount
||
nodeReader
.
getCodePointCount
()
<=
0
)
{
// The nodePos is not a valid terminal node position in the dictionary.
*
outUnigramProbability
=
NOT_A_PROBABILITY
;
return
0
;
}
// Read parent node.
nodeReader
.
fetchNodeInfoFromBufferAndGetNodeCodePoints
(
nodeReader
.
getParentPos
(),
maxCodePointCount
,
mergedNodeCodePoints
);
// Store node code points to buffer in the reverse order.
for
(
int
i
=
nodeReader
.
getCodePointCount
()
-
1
;
i
>=
0
;
--
i
)
{
reverseCodePoints
[
codePointCount
++
]
=
mergedNodeCodePoints
[
i
];
}
}
// Reverse the stored code points to output them.
for
(
int
i
=
0
;
i
<
codePointCount
;
++
i
)
{
outCodePoints
[
i
]
=
reverseCodePoints
[
codePointCount
-
i
-
1
];
}
return
codePointCount
;
}
int
DynamicPatriciaTriePolicy
::
getTerminalNodePositionOfWord
(
...
...
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