My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Copyright 2010 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.googlecode.tcime;

import android.content.Context;
import android.util.Log;

import java.util.concurrent.CountDownLatch;

/**
* Reads a word-dictionary and provides word-suggestions as a list of characters
* for the specified input.
*/
public abstract class WordDictionary {

private final CountDownLatch loading = new CountDownLatch(1);
private final DictionaryLoader loader;

protected WordDictionary(
Context context, int dictionaryId, int approxDictionarySize) {
loader = new DictionaryLoader(
context.getResources().openRawResource(dictionaryId),
approxDictionarySize, loading);
new Thread(loader).start();
}

protected char[][] dictionary() {
try {
loading.await();
} catch (InterruptedException e) {
Log.e("WordDictionary", "Loading is interrupted: ", e);
}
return loader.result();
}

/**
* Returns a string containing words as suggestions for the specified input.
*
* @param input should not be null.
* @return a concatenated string of characters, or an empty string if there
* is no word for that input.
*/
public abstract String getWords(CharSequence input);
}

Change log

r3 by super.brother3 on Mar 19, 2010   Diff
Move package
Go to: 
Project members, sign in to write a code review

Older revisions

r2 by super.brother3 on Mar 18, 2010   Diff
Initial checkin.
All revisions of this file

File info

Size: 1780 bytes, 58 lines
Powered by Google Project Hosting