Package com.sohospace.dictionary

Examples of com.sohospace.dictionary.Hit


  protected void collect(Collector collector, CharSequence beaf, int offset,
      int end, String word) {
    super.collect(collector, beaf, offset, end, word);
    if (units != null) {
      Hit wd;
      int i = end + 1;
      while (i <= beaf.length()
          && (wd = units.search(beaf, end, i - end)).isHit()) {
        collector.collect(word + beaf.subSequence(end, i), offset, i);
        end++;
        if (!wd.isUnclosed()) {
          break;
        }
        i++;
      }
    }
View Full Code Here


    int identifiedEnd = offset;
    // ���ڶ�λδ�ִܷʵĿ�Ŀ�ʼλ�ã�e.g '��'
    int unidentifiedIndex = -1;
    //���ڸ����ж��Ƿ����shouldAWord()����
    int maxWordLength = 0;
    Hit word = null;
    for (setup = offset, end = offset; setup < beaf.length()
        && CharSet.isCjkUnifiedIdeographs(beaf.charAt(setup)); end = ++setup) {
      for (int count = 1; end < beaf.length()
          && CharSet.isCjkUnifiedIdeographs(beaf.charAt(end++)); count++) {
        //��һ��forѭ��ʱ��end=setup+1
        word = vocabulary.search(beaf, setup, count);
        if (word.isUndefined()) {
          if (unidentifiedIndex < 0 && setup >= identifiedEnd) {
            unidentifiedIndex = setup;
          }
          break;
        } else if (word.isHit()) {
          if (identifiedEnd < end) {
            identifiedEnd = end;
          }
          if (unidentifiedIndex >= 0) {
            dissectUnidentified(collector, beaf, unidentifiedIndex,
                setup - unidentifiedIndex);
            unidentifiedIndex = -1;
          }
          collector.collect(word.getWord(), setup, end);
          if (setup == offset && maxWordLength < count) {
            maxWordLength = count;
          }
          if (!(word.isUnclosed() && end < beaf.length()// ����ж���Ϊ�����жϷ���
          && beaf.charAt(end) >= word.getNext().charAt(count))) {
            break;
          }
        }
      }
    }
View Full Code Here

   * @param count
   */
  protected void dissectUnidentified(Collector collector, CharSequence beaf,
      int offset, int count) {
    int end = offset + count;
    Hit word = null;
    int nearEnd = end - 1;
    for (int i = offset, j=i; i < end;) {
      j = skipXword(beaf, i, end);
      if (j >= 0 && i != j) {
        i = j;
        continue;
      }
      j = collectNumber(collector, beaf, i, end);
      if (j >= 0 && i != j) {
        i = j;
        continue;
      }
      word = factory.getXchars().search(beaf, i, 1);
      if (word.isHit()) {
        i++;
        continue;
      }
      // ͷ��
      if (i == offset) {
View Full Code Here

      int offset, int end) {
    collector.collect(beaf.subSequence(offset, end).toString(), offset, end);
  }

  private final int skipXword(CharSequence beaf, int offset, int end) {
    Hit word;
    for (int k = offset + 2; k <= end; k++) {
      word = factory.getXwords().search(beaf, offset, k - offset);
      if (word.isHit()) {
        offset = k;
      }
      if (word.isUndefined() || !word.isUnclosed()) {
        break;
      }
    }
    return offset;
  }
View Full Code Here

TOP

Related Classes of com.sohospace.dictionary.Hit

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.