Esempio n. 1
0
  protected IWord[] findMatchWords(char[] chars, int index) {
    IDictionary dictionary = DictionaryFactoryImpl.createDictionary();

    char c = chars[index];

    List matchWords = new ArrayList();

    StringBuffer sb = new StringBuffer();
    sb.append(c);

    String wordValue = sb.toString();
    if (dictionary.isMatched(wordValue)) {
      matchWords.add(dictionary.getWord(wordValue));
    }

    for (int i = 1; i < Config.WORD_MAX_LENGTH && ((i + index) < chars.length); i++) {
      if (isBasicLatin(chars[i + index])) break;
      sb.append(chars[i + index]);
      String temp = sb.toString();
      if (dictionary.isMatched(temp)) {
        matchWords.add(dictionary.getWord(temp));
      }
    }

    if (matchWords.isEmpty()) {
      matchWords.add(new Word(wordValue, Word.UNRECOGNIZED));
    }

    IWord[] words = new IWord[matchWords.size()];
    matchWords.toArray(words);

    matchWords.clear();

    return words;
  }