Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c9a29986 authored by Jean Chalard's avatar Jean Chalard Committed by The Android Automerger
Browse files

[ML23] Introduce a different accuracy/performance tradeoff

Bug: 11230254
Change-Id: Ic09518c818ae7b68942b1c63160dd462e5922cb5
parent b0f3e62e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -292,6 +292,7 @@ public final class BinaryDictionary extends Dictionary {
                settingsValuesForSuggestion.mSpaceAwareGestureEnabled);
        session.mNativeSuggestOptions.setAdditionalFeaturesOptions(
                settingsValuesForSuggestion.mAdditionalFeaturesSettingValues);
        session.mNativeSuggestOptions.setWeightForLocale(weightForLocale);
        if (inOutWeightOfLangModelVsSpatialModel != null) {
            session.mInputOutputWeightOfLangModelVsSpatialModel[0] =
                    inOutWeightOfLangModelVsSpatialModel[0];
+8 −1
Original line number Diff line number Diff line
@@ -22,7 +22,8 @@ public class NativeSuggestOptions {
    private static final int USE_FULL_EDIT_DISTANCE = 1;
    private static final int BLOCK_OFFENSIVE_WORDS = 2;
    private static final int SPACE_AWARE_GESTURE_ENABLED = 3;
    private static final int OPTIONS_SIZE = 4;
    private static final int WEIGHT_FOR_LOCALE_IN_THOUSANDS = 4;
    private static final int OPTIONS_SIZE = 5;

    private final int[] mOptions = new int[OPTIONS_SIZE
            + AdditionalFeaturesSettingUtils.ADDITIONAL_FEATURES_SETTINGS_SIZE];
@@ -43,6 +44,12 @@ public class NativeSuggestOptions {
        setBooleanOption(SPACE_AWARE_GESTURE_ENABLED, value);
    }

    public void setWeightForLocale(final float value) {
        // We're passing this option as a fixed point value, in thousands. This is decoded in
        // native code by SuggestOptions#weightForLocale().
        setIntegerOption(WEIGHT_FOR_LOCALE_IN_THOUSANDS, (int) (value * 1000));
    }

    public void setAdditionalFeaturesOptions(final int[] additionalOptions) {
        if (additionalOptions == null) {
            return;
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ class Traversal {
    virtual bool needsToTraverseAllUserInput() const = 0;
    virtual float getMaxSpatialDistance() const = 0;
    virtual int getDefaultExpandDicNodeSize() const = 0;
    virtual int getMaxCacheSize(const int inputSize) const = 0;
    virtual int getMaxCacheSize(const int inputSize, const float weightForLocale) const = 0;
    virtual int getTerminalCacheSize() const = 0;
    virtual bool isPossibleOmissionChildNode(const DicTraverseSession *const traverseSession,
            const DicNode *const parentDicNode, const DicNode *const dicNode) const = 0;
+3 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include "suggest/core/policy/weighting.h"
#include "suggest/core/result/suggestions_output_utils.h"
#include "suggest/core/session/dic_traverse_session.h"
#include "suggest/core/suggest_options.h"

namespace latinime {

@@ -88,7 +89,8 @@ void Suggest::initializeSearch(DicTraverseSession *traverseSession) const {
        traverseSession->getDicTraverseCache()->continueSearch();
    } else {
        // Restart recognition at the root.
        traverseSession->resetCache(TRAVERSAL->getMaxCacheSize(traverseSession->getInputSize()),
        traverseSession->resetCache(TRAVERSAL->getMaxCacheSize(traverseSession->getInputSize(),
                traverseSession->getSuggestOptions()->weightForLocale()),
                TRAVERSAL->getTerminalCacheSize());
        // Create a new dic node here
        DicNode rootNode;
+8 −1
Original line number Diff line number Diff line
@@ -42,6 +42,12 @@ class SuggestOptions{
        return getBoolOption(SPACE_AWARE_GESTURE_ENABLED);
    }

    AK_FORCE_INLINE float weightForLocale() const {
        // The weight is in thousands and we want the real value, so we divide by 1000.
        // NativeSuggestOptions#setWeightForLocale does the opposite processing in Java.
        return static_cast<float>(getIntOption(WEIGHT_FOR_LOCALE_IN_THOUSANDS)) / 1000.0f;
    }

    AK_FORCE_INLINE bool getAdditionalFeaturesBoolOption(const int key) const {
        return getBoolOption(key + ADDITIONAL_FEATURES_OPTIONS);
    }
@@ -55,9 +61,10 @@ class SuggestOptions{
    static const int USE_FULL_EDIT_DISTANCE = 1;
    static const int BLOCK_OFFENSIVE_WORDS = 2;
    static const int SPACE_AWARE_GESTURE_ENABLED = 3;
    static const int WEIGHT_FOR_LOCALE_IN_THOUSANDS = 4;
    // Additional features options are stored after the other options and used as setting values of
    // experimental features.
    static const int ADDITIONAL_FEATURES_OPTIONS = 4;
    static const int ADDITIONAL_FEATURES_OPTIONS = 5;

    const int *const mOptions;
    const int mLength;
Loading