Home | History | Annotate | Download | only in personalization
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.inputmethod.latin.personalization;
     18 
     19 import android.content.Context;
     20 
     21 import com.android.inputmethod.annotations.UsedForTesting;
     22 import com.android.inputmethod.latin.Dictionary;
     23 import com.android.inputmethod.latin.ExpandableBinaryDictionary;
     24 
     25 import java.io.File;
     26 import java.util.Locale;
     27 
     28 public class ContextualDictionary extends ExpandableBinaryDictionary {
     29     /* package */ static final String NAME = ContextualDictionary.class.getSimpleName();
     30 
     31     private ContextualDictionary(final Context context, final Locale locale,
     32             final File dictFile) {
     33         super(context, getDictName(NAME, locale, dictFile), locale, Dictionary.TYPE_CONTEXTUAL,
     34                 dictFile);
     35         // Always reset the contents.
     36         clear();
     37     }
     38 
     39     @UsedForTesting
     40     public static ContextualDictionary getDictionary(final Context context, final Locale locale,
     41             final File dictFile, final String dictNamePrefix) {
     42         return new ContextualDictionary(context, locale, dictFile);
     43     }
     44 
     45     @Override
     46     public boolean isValidWord(final String word) {
     47         // Strings out of this dictionary should not be considered existing words.
     48         return false;
     49     }
     50 
     51     @Override
     52     protected void loadInitialContentsLocked() {
     53     }
     54 }
     55