Package net.paoding.analysis.dictionary

Examples of net.paoding.analysis.dictionary.Word


        break;
      }
    }
    int index = wordText.indexOf('[');
    if (index == -1) {
      words.add(new Word(wordText));
    }
    else {
      Word w = new Word(wordText.substring(0, index));
      int mindex = wordText.indexOf("m=", index);
      if (mindex != -1) {
        int mEndIndex = wordText.indexOf("]", mindex);
        String m = wordText.substring(mindex + "m=".length(), mEndIndex);
        w.setModifiers(Integer.parseInt(m));
        words.add(w);
      }
    }
  }
View Full Code Here


    }
    BufferedOutputStream out = new BufferedOutputStream(
        new FileOutputStream(dicFile), 1024 * 16);
   
    for (int i = 0; i < wordsSize; i++) {
      Word word = dictionary.get(i);
      out.write(word.getText().getBytes(charsetName));
      if (word.getModifiers() != Word.DEFAUL) {
        out.write("[m=".getBytes());
        out.write(String.valueOf(word.getModifiers()).getBytes());
        out.write(']');
      }
      out.write('\r');
      out.write('\n');
    }
View Full Code Here

      IOException, UnsupportedEncodingException {
    int vocabularySize = vocabularyDictionary.size();
    Word[] vocabularyWords = new Word[vocabularySize];
    char[] chs = new char[128];
    for (int i = 0; i < vocabularySize; i ++) {
      final Word curWord = vocabularyDictionary.get(i);
      curWord.getText().getChars(0, curWord.length(), chs, 0);
      chs[curWord.length()] = (char) -1;
      Beef beef = new Beef(chs, 0, curWord.length() + 1);
      final BitSet bs = new BitSet(curWord.length());
      knife.dissect(new Collector(){
        public void collect(String word, int offset, int end) {
          Hit hit = vocabularyDictionary.search(word, 0, word.length());
          if (hit.isHit() && hit.getWord().length() != curWord.length()) {
            for (int j = offset; j < end; j++) {
              bs.set(j, true);
            }
          }
        }
       
      }, beef, 0);
     
      for (int j = 0; j < curWord.length();j++) {
        if (!bs.get(j)) {
          vocabularyWords[i] = curWord;
          break;
        }
      }
View Full Code Here

    }
    BufferedOutputStream out = new BufferedOutputStream(
        new FileOutputStream(dicFile), 1024 * 16);
   
    for (int i = 0; i < wordsSize; i++) {
      Word word = dictionary.get(i);
      out.write(word.getText().getBytes(charsetName));
      if (word.getModifiers() != Word.DEFAUL) {
        out.write("[m=".getBytes());
        out.write(String.valueOf(word.getModifiers()).getBytes());
        out.write(']');
      }
      out.write('\r');
      out.write('\n');
    }
View Full Code Here

TOP

Related Classes of net.paoding.analysis.dictionary.Word

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.