Package joshua.corpus

Examples of joshua.corpus.Phrase


  }
 
  @Test(dependsOnMethods = {"basicPattern"})
  public void copiedPattern() {
   
    Phrase phrase = pattern;
   
    Pattern copiedPattern = new Pattern(phrase);
   
    Assert.assertEquals(copiedPattern.getWordIDs().length, words.length);
    for (int i=0; i<words.length; i++) {
View Full Code Here


   
    Iterator<Map.Entry<Phrase,Integer>> i = map.entrySet().iterator();
    Assert.assertNotNull(i);
   
    Map.Entry<Phrase, Integer> entry;
    Phrase phrase;
   
    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertEquals(phrase.toString(), "the");
 
    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertEquals(phrase.toString(), "of");
   
    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertEquals(phrase.toString(), "to");
   
    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertEquals(phrase.toString(), "that");
   
   
    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertEquals(phrase.toString(), ".");
   
    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertEquals(phrase.toString(), "chromosome");

    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertEquals(phrase.toString(), "genes");
   
    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertEquals(phrase.toString(), ",");
   
    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertEquals(phrase.toString(), "is");
   
    Assert.assertFalse(i.hasNext());
   
  }
View Full Code Here

    LinkedHashMap<Phrase,Short> ranks = frequentPhrases.getRanks();
    Iterator<Map.Entry<Phrase,Short>> i = ranks.entrySet().iterator();
    Assert.assertNotNull(i);
   
    Map.Entry<Phrase,Short> entry;
    Phrase phrase;
    short rank;
   
    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertNotNull(phrase);
    Assert.assertEquals(phrase.toString(), "the");
    rank = entry.getValue();
    Assert.assertEquals(rank, 0);
   
    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertNotNull(phrase);
    Assert.assertEquals(phrase.toString(), "of");
    rank = entry.getValue();
    Assert.assertEquals(rank, 1);
   
    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertNotNull(phrase);
    Assert.assertEquals(phrase.toString(), "to");
    rank = entry.getValue();
    Assert.assertEquals(rank, 2);
   
    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertNotNull(phrase);
    Assert.assertEquals(phrase.toString(), "that");
    rank = entry.getValue();
    Assert.assertEquals(rank, 3);
   
    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertNotNull(phrase);
    Assert.assertEquals(phrase.toString(), ".");
    rank = entry.getValue();
    Assert.assertEquals(rank, 4);
   
    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertNotNull(phrase);
    Assert.assertEquals(phrase.toString(), "chromosome");
    rank = entry.getValue();
    Assert.assertEquals(rank, 5);
   
    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertNotNull(phrase);
    Assert.assertEquals(phrase.toString(), "genes");
    rank = entry.getValue();
    Assert.assertEquals(rank, 6);

    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertNotNull(phrase);
    Assert.assertEquals(phrase.toString(), ",");
    rank = entry.getValue();
    Assert.assertEquals(rank, 7);
   
    Assert.assertTrue(i.hasNext());
    entry = i.next();
    phrase = entry.getKey();
    Assert.assertNotNull(phrase);
    Assert.assertEquals(phrase.toString(), "is");
    rank = entry.getValue();
    Assert.assertEquals(rank, 8);
   
    Assert.assertFalse(i.hasNext());
  }
View Full Code Here

   
    // Adam Lopez's example...
    String corpusString = "it makes him and it mars him , it sets him on and it takes him off .";

    vocab = new Vocabulary();
    Phrase exampleSentence = new BasicPhrase(corpusString, vocab);
   
    exampleSentence = new BasicPhrase(corpusString, vocab);
    int[] sentences = new int[1];
    sentences[0] = 0;
    int[] corpus = new int[exampleSentence.size()];
    for(int i = 0; i < exampleSentence.size(); i++) {
      corpus[i] = exampleSentence.getWordID(i);
    }
   
    CorpusArray corpusArray = new CorpusArray(corpus, sentences, vocab);
   
    if (binaryFileName==null || binaryFileName.trim().length()==0)
View Full Code Here

  @Test
  public void findPhrase() {
   
    // Look up phrase "it makes him"
   
    Phrase phrase = new BasicPhrase("it makes him", vocab);
    int[] bounds = suffixArray.findPhrase(phrase);
   
    int expectedSuffixArrayStartIndex = 0;
    int expectedSuffixArrayEndIndex = 0;
   
View Full Code Here

    }
    List<Phrase> phrases = new ArrayList<Phrase>();
   
    for (int i = 0; i < size(); i++) {
      for (int j = i + 1; (j <= size()) && (j - i <= maxLength); j++) {
        Phrase subPhrase = subPhrase(i,j);
        phrases.add(subPhrase);
      }
    }
    return phrases;
  }
View Full Code Here

       
        // Verify that the sentence end position in the memory-mapped corpus and the in-memory corpus have the same value
        Assert.assertEquals(mmCorpus.getSentenceEndPosition(i), corpus.getSentenceEndPosition(i));
       
        // Verify that the phrase corresponding to this sentence is the same
        Phrase sentence = corpus.getSentence(i);
        Phrase mmSentence = mmCorpus.getSentence(i);
        Assert.assertNotNull(sentence);
        Assert.assertNotNull(mmSentence);
        Assert.assertEquals(mmSentence, sentence);
      }
     
View Full Code Here

TOP

Related Classes of joshua.corpus.Phrase

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.