Examples of WordEntry


Examples of com.ansj.vec.domain.WordEntry

  }

  private void insertTopN(String name, float score, List<WordEntry> wordsEntrys) {
    // TODO Auto-generated method stub
    if (wordsEntrys.size() < topNSize) {
      wordsEntrys.add(new WordEntry(name, score));
      return;
    }
    float min = Float.MAX_VALUE;
    int minOffe = 0;
    for (int i = 0; i < topNSize; i++) {
      WordEntry wordEntry = wordsEntrys.get(i);
      if (min > wordEntry.score) {
        min = wordEntry.score;
        minOffe = i;
      }
    }

    if (score > min) {
      wordsEntrys.set(minOffe, new WordEntry(name, score));
    }

  }
View Full Code Here

Examples of com.ansj.vec.domain.WordEntry

      for (int i = 0; i < vector.length; i++) {
        dist += center[i] * vector[i];
      }

      if (dist > min) {
        result.add(new WordEntry(entry.getKey(), dist));
        if (resultSize < result.size()) {
          result.pollLast();
        }
        min = result.last().score;
      }
View Full Code Here

Examples of com.ansj.vec.domain.WordEntry

      for (int i = 0; i < vector.length; i++) {
        dist += center[i] * vector[i];
      }

      if (dist > min) {
        result.add(new WordEntry(entry.getKey(), dist));
        if (resultSize < result.size()) {
          result.pollLast();
        }
        min = result.last().score;
      }
View Full Code Here

Examples of games.stendhal.common.parser.WordEntry

*/
public class WordEntryTest {

  @Test
  public final void testWordEntry() {
    final WordEntry w = new WordEntry();
    assertEquals("/", w.getNormalizedWithTypeString());
    assertEquals("/", w.toString());

    w.setNormalized("norm");
    w.setPlurSing("plur");
    assertEquals("norm/", w.getNormalizedWithTypeString());
    assertEquals("norm/", w.toString());

    w.setType(new ExpressionType("TYP"));
    w.setValue(4711);
    assertEquals("norm/TYP", w.getNormalizedWithTypeString());
    assertEquals("norm/TYP", w.toString());
  }
View Full Code Here

Examples of games.stendhal.common.parser.WordEntry

  @Test
  public final void testNouns() {
    final WordList wl = WordList.getInstance();

    WordEntry w = wl.find("house");
    assertNotNull(w);
    assertTrue(w.getType().isObject());
    assertEquals(ExpressionType.OBJECT, w.getTypeString());
    assertFalse(w.isPlural());
    assertEquals("houses", w.getPlurSing());

    w = wl.find("man");
    assertNotNull(w);
    assertTrue(w.getType().isSubject());
    assertEquals(ExpressionType.SUBJECT, w.getTypeString());
    assertFalse(w.isPlural());
    assertEquals("men", w.getPlurSing());

    w = wl.find("men");
    assertNotNull(w);
    assertTrue(w.getType().isSubject());
    assertEquals(ExpressionType.SUBJECT+ExpressionType.SUFFIX+ExpressionType.PLURAL, w.getTypeString());
    assertTrue(w.isPlural());
    assertEquals("man", w.getPlurSing());

    w = wl.find("carrot");
    assertNotNull(w);
    assertTrue(w.getType().isObject());
    assertEquals(ExpressionType.OBJECT + ExpressionType.SUFFIX_FOOD, w.getTypeString());
    assertFalse(w.isPlural());
    assertEquals("carrots", w.getPlurSing());

    w = wl.find("carrots");
    assertNotNull(w);
    assertTrue(w.getType().isObject());
    assertEquals(ExpressionType.OBJECT + ExpressionType.SUFFIX_FOOD + ExpressionType.SUFFIX_PLURAL, w.getTypeString());
    assertTrue(w.isPlural());
    assertEquals("carrot", w.getPlurSing());

    w = wl.find("water");
    assertNotNull(w);
    assertTrue(w.getType().isObject());
    assertEquals(ExpressionType.OBJECT + ExpressionType.SUFFIX_FOOD + ExpressionType.SUFFIX_FLUID, w.getTypeString());
    assertEquals("waters", w.getPlurSing());

    w = wl.find("she");
    assertNotNull(w);
    assertTrue(w.getType().isSubject());
    assertEquals(ExpressionType.SUBJECT + ExpressionType.SUFFIX_PRONOUN, w.getTypeString());
    assertEquals("they", w.getPlurSing());
  }
View Full Code Here

Examples of games.stendhal.common.parser.WordEntry

   */
  @Test
  public final void testVerbs() {
    final WordList wl = WordList.getInstance();

    WordEntry w = wl.find("say");
    assertNotNull(w);
    assertTrue(w.getType().isVerb());
    assertEquals(ExpressionType.VERB, w.getTypeString());

    w = wl.find("open");
    assertNotNull(w);
    assertTrue(w.getType().isVerb());
    assertEquals(ExpressionType.VERB, w.getTypeString());

    w = wl.find("are");
    assertNotNull(w);
    assertTrue(w.getType().isVerb());
    assertEquals(ExpressionType.VERB + ExpressionType.SUFFIX_PLURAL, w.getTypeString());
  }
View Full Code Here

Examples of games.stendhal.common.parser.WordEntry

   */
  @Test
  public final void testAdjectives() {
    final WordList wl = WordList.getInstance();

    WordEntry w = wl.find("white");
    assertNotNull(w);
    assertTrue(w.getType().isAdjective());
    assertEquals(ExpressionType.ADJECTIVE + ExpressionType.SUFFIX_COLOR, w.getTypeString());

    w = wl.find("silvery");
    assertNotNull(w);
    assertTrue(w.getType().isAdjective());
    assertEquals(ExpressionType.ADJECTIVE + ExpressionType.SUFFIX_COLOR, w.getTypeString());

    w = wl.find("nomadic");
    assertNotNull(w);
    assertTrue(w.getType().isAdjective());
    assertEquals(ExpressionType.ADJECTIVE, w.getTypeString());
  }
View Full Code Here

Examples of games.stendhal.common.parser.WordEntry

   */
  @Test
  public final void testPrepositions() {
    final WordList wl = WordList.getInstance();

    WordEntry w = wl.find("with");
    assertNotNull(w);
    assertTrue(w.getType().isPreposition());
    assertEquals(ExpressionType.PREPOSITION, w.getTypeString());

    w = wl.find("on");
    assertNotNull(w);
    assertTrue(w.getType().isPreposition());
    assertEquals(ExpressionType.PREPOSITION, w.getTypeString());
  }
View Full Code Here

Examples of games.stendhal.common.parser.WordEntry

    assertEquals("three\tNUM\t3", printWord(wl, "three"));
    assertEquals("houses\tOBJ-PLU\thouse", printWord(wl, "houses"));
  }

  private String printWord(final WordList wl, String word) {
    WordEntry w = wl.find(word);
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    w.print(pw, word);

    return sw.toString();
  }
View Full Code Here

Examples of org.teiid.internal.core.index.WordEntry

        super(name);
    }

    public void testAddAndRetrieveEntry() {
        IndexBlock indexBlock = new GammaCompressedIndexBlock(IIndexConstants.BLOCK_SIZE);
        WordEntry entry = new WordEntry();
        //adding entries - 256 chars
        char[] word = "12345678 abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn".toCharArray();//$NON-NLS-1$
        entry.reset(word);
        entry.addRef(1);
        indexBlock.addEntry(entry);
       
        word = "12345678 abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn abceabcdefghijklmn q".toCharArray();//$NON-NLS-1$
        entry.reset(word);
        entry.addRef(1);
        indexBlock.addEntry(entry);
       
        //reading entries
        indexBlock.reset();
        indexBlock.nextEntry(entry);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.