mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Use CodePointArrayView in DictionaryUtils.
Change-Id: I9ae308e60124ea5acb4ee09847c4fdd58ff168e2
This commit is contained in:
parent
3e75c59133
commit
fc7d0540fe
@ -109,7 +109,7 @@ int Dictionary::getProbability(const CodePointArrayView codePoints) const {
|
||||
int Dictionary::getMaxProbabilityOfExactMatches(const CodePointArrayView codePoints) const {
|
||||
TimeKeeper::setCurrentTime();
|
||||
return DictionaryUtils::getMaxProbabilityOfExactMatches(
|
||||
mDictionaryStructureWithBufferPolicy.get(), codePoints.data(), codePoints.size());
|
||||
mDictionaryStructureWithBufferPolicy.get(), codePoints);
|
||||
}
|
||||
|
||||
int Dictionary::getNgramProbability(const PrevWordsInfo *const prevWordsInfo,
|
||||
|
@ -29,7 +29,7 @@ namespace latinime {
|
||||
|
||||
/* static */ int DictionaryUtils::getMaxProbabilityOfExactMatches(
|
||||
const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy,
|
||||
const int *const codePoints, const int codePointCount) {
|
||||
const CodePointArrayView codePoints) {
|
||||
std::vector<DicNode> current;
|
||||
std::vector<DicNode> next;
|
||||
|
||||
@ -40,16 +40,16 @@ namespace latinime {
|
||||
dictionaryStructurePolicy, &prevWordIdArray, false /* tryLowerCaseSearch */);
|
||||
current.emplace_back();
|
||||
DicNodeUtils::initAsRoot(dictionaryStructurePolicy, prevWordIds, ¤t.front());
|
||||
for (int i = 0; i < codePointCount; ++i) {
|
||||
for (const int codePoint : codePoints) {
|
||||
// The base-lower input is used to ignore case errors and accent errors.
|
||||
const int codePoint = CharUtils::toBaseLowerCase(codePoints[i]);
|
||||
const int baseLowerCodePoint = CharUtils::toBaseLowerCase(codePoint);
|
||||
for (const DicNode &dicNode : current) {
|
||||
if (dicNode.isInDigraph() && dicNode.getNodeCodePoint() == codePoint) {
|
||||
if (dicNode.isInDigraph() && dicNode.getNodeCodePoint() == baseLowerCodePoint) {
|
||||
next.emplace_back(dicNode);
|
||||
next.back().advanceDigraphIndex();
|
||||
continue;
|
||||
}
|
||||
processChildDicNodes(dictionaryStructurePolicy, codePoint, &dicNode, &next);
|
||||
processChildDicNodes(dictionaryStructurePolicy, baseLowerCodePoint, &dicNode, &next);
|
||||
}
|
||||
current.clear();
|
||||
current.swap(next);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "defines.h"
|
||||
#include "utils/int_array_view.h"
|
||||
|
||||
namespace latinime {
|
||||
|
||||
@ -30,7 +31,7 @@ class DictionaryUtils {
|
||||
public:
|
||||
static int getMaxProbabilityOfExactMatches(
|
||||
const DictionaryStructureWithBufferPolicy *const dictionaryStructurePolicy,
|
||||
const int *const codePoints, const int codePointCount);
|
||||
const CodePointArrayView codePoints);
|
||||
|
||||
private:
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(DictionaryUtils);
|
||||
|
Loading…
Reference in New Issue
Block a user