Package joshua.corpus.vocab

Examples of joshua.corpus.vocab.SymbolTable


//  @SuppressWarnings("deprecation")
  @Test(dependsOnMethods={"setup"})
  public void testHasAlignedTerminal() {
    {

      SymbolTable vocab = sourceCorpusArray.getVocabulary();
     
      {
//        Pattern     pattern = new Pattern(vocab, vocab.getIDs("de sesiones del parlamento europeo"));
//        int[]       terminalSequenceStartIndices = {4};
//        int[]       terminalSequenceEndIndices = {9};
//        int         length = 5;

        Span span = new Span(4,9);
       
        int[] words = vocab.getIDs("de sesiones del parlamento europeo");
        List<LabeledSpan> labeledSpans = Collections.<LabeledSpan>emptyList();
       
        HierarchicalPhrase phrase =
          new HierarchicalPhrase(
              words,
              span,
              labeledSpans,
              sourceCorpusArray);
       
//        HierarchicalPhrase phrase =
//          new HierarchicalPhrase(
//              vocab.getIDs("de sesiones del parlamento europeo"),
//              terminalSequenceStartIndices,
//              terminalSequenceEndIndices,
//              sourceCorpusArray,
//              length);

        Assert.assertFalse(phrase.containsTerminalAt(0));
        Assert.assertFalse(phrase.containsTerminalAt(1));
        Assert.assertFalse(phrase.containsTerminalAt(2));
        Assert.assertFalse(phrase.containsTerminalAt(3));

        Assert.assertTrue(phrase.containsTerminalAt(4));
        Assert.assertTrue(phrase.containsTerminalAt(5));
        Assert.assertTrue(phrase.containsTerminalAt(6));
        Assert.assertTrue(phrase.containsTerminalAt(7));
        Assert.assertTrue(phrase.containsTerminalAt(8));

        Assert.assertFalse(phrase.containsTerminalAt(9));
        Assert.assertFalse(phrase.containsTerminalAt(10));
        Assert.assertFalse(phrase.containsTerminalAt(11));

        Assert.assertFalse(phrase.containsTerminalAt(Integer.MAX_VALUE));
        Assert.assertFalse(phrase.containsTerminalAt(-1));
      }
     
      {
//        Pattern     pattern = new Pattern(vocab, vocab.getIDs(","));
//        int[]       terminalSequenceStartIndices = {9};
//        int[]       terminalSequenceEndIndices = {10};
//        int         length = 1;

        HierarchicalPhrase phrase =
          new HierarchicalPhrase(
              vocab.getIDs(","),
              new Span(9,10),
              Collections.<LabeledSpan>emptyList(),
              sourceCorpusArray);
       
//        HierarchicalPhrase phrase =
View Full Code Here


    locations.add(new IntegerPair(position1, position2));
  }
 
  List<HierarchicalPhrases> getHierarchicalPhrases() {
   
    SymbolTable vocab = corpus.getVocabulary();
    int X = vocab.addNonterminal("X");
   
    List<HierarchicalPhrases> result = new ArrayList<HierarchicalPhrases>();
   
    for (Map.Entry<Pair<Phrase,Phrase>,List<IntegerPair>> entry : phrasePairCollocations.entrySet()) {
      Pair<Phrase,Phrase> phrasePair = entry.getKey();
View Full Code Here

 

  @Test(dependsOnMethods={"setup"})
  public void testHasAlignedTerminal() {
   
    SymbolTable vocab = sourceCorpusArray.getVocabulary();
   
    {
      Pattern     pattern = new Pattern(vocab, vocab.getIDs("de sesiones del parlamento europeo"));
      int[]       terminalSequenceStartIndices = {4};
      int[]       sentenceNumbers = {0};
      int phraseIndex = 0;
     
      HierarchicalPhrases phrases =
        new HierarchicalPhrases(pattern, terminalSequenceStartIndices, sentenceNumbers);
     
     
     
      Assert.assertFalse(alignments.hasAlignedTerminal(0 , phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(1 , phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(2 , phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(3 , phrases, phraseIndex));

      Assert.assertTrue(alignments.hasAlignedTerminal(4 , phrases, phraseIndex));
      Assert.assertTrue(alignments.hasAlignedTerminal(5 , phrases, phraseIndex));
      Assert.assertTrue(alignments.hasAlignedTerminal(6 , phrases, phraseIndex));
      Assert.assertTrue(alignments.hasAlignedTerminal(7 , phrases, phraseIndex));
      Assert.assertTrue(alignments.hasAlignedTerminal(8 , phrases, phraseIndex));

      Assert.assertFalse(alignments.hasAlignedTerminal(9 , phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(10 , phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(11 , phrases, phraseIndex));
    }
 
   
    {
      Pattern     pattern = new Pattern(vocab, vocab.getIDs(","));
      int[]       terminalSequenceStartIndices = {9};
      int[]       sentenceNumbers = {0};
      int phraseIndex = 0;

      HierarchicalPhrases phrases =
View Full Code Here

  @Test(dependsOnMethods={"setup"})
  public void testHasAlignedTerminalHierarchical() {
   
   
 
    SymbolTable vocab = sourceCorpusArray.getVocabulary();
   
    {
      Pattern     pattern = new Pattern(new Pattern(new Pattern(vocab, vocab.getIDs("de sesiones")), SymbolTable.X), vocab.getIDs("europo"));// del parlamento europeo"));
      int[]       terminalSequenceStartIndices = {4,8};
      int[]       sentenceNumbers = {0};
      int phraseIndex = 0;
     
      HierarchicalPhrases phrases =
        new HierarchicalPhrases(pattern, terminalSequenceStartIndices, sentenceNumbers);
//      HierarchicalPhrase phrase = new HierarchicalPhrase(pattern, terminalSequenceStartIndices, terminalSequenceEndIndices, sourceCorpusArray, length);

      Assert.assertFalse(alignments.hasAlignedTerminal(0 , phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(1 , phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(2 , phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(3 , phrases, phraseIndex));

      Assert.assertTrue(alignments.hasAlignedTerminal(4 , phrases, phraseIndex));
      Assert.assertTrue(alignments.hasAlignedTerminal(5 , phrases, phraseIndex));
      Assert.assertTrue(alignments.hasAlignedTerminal(6 , phrases, phraseIndex));
      Assert.assertTrue(alignments.hasAlignedTerminal(7 , phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(8 , phrases, phraseIndex));

      Assert.assertFalse(alignments.hasAlignedTerminal(9 , phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(10 , phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(11 , phrases, phraseIndex));

    }
   
    {
      Pattern     pattern = new Pattern(new Pattern(new Pattern(vocab, vocab.getIDs(", y")), PrefixTree.X), vocab.getIDs("sus"));// del parlamento europeo"));
      int[]       terminalSequenceStartIndices = {17,21};
      int[]       sentenceNumbers = {0};
      int phraseIndex = 0;
     
      HierarchicalPhrases phrases =
        new HierarchicalPhrases(pattern, terminalSequenceStartIndices, sentenceNumbers);
     
      Assert.assertFalse(alignments.hasAlignedTerminal(12 , phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(13 , phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(14 , phrases, phraseIndex));

      Assert.assertTrue(alignments.hasAlignedTerminal(15, phrases, phraseIndex));
      Assert.assertTrue(alignments.hasAlignedTerminal(16, phrases, phraseIndex));
     
      Assert.assertFalse(alignments.hasAlignedTerminal(17, phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(18, phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(19, phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(20, phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(21, phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(22, phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(23, phrases, phraseIndex));
     
      Assert.assertTrue(alignments.hasAlignedTerminal(24, phrases, phraseIndex));

      Assert.assertFalse(alignments.hasAlignedTerminal(25, phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(26, phrases, phraseIndex));
      Assert.assertFalse(alignments.hasAlignedTerminal(27, phrases, phraseIndex));
     
    }
   
    {

      Pattern     pattern = new Pattern(new Pattern(new Pattern(vocab, vocab.getIDs(",")), PrefixTree.X), vocab.getIDs(", y"));// del parlamento europeo"));
      int[]       terminalSequenceStartIndices = {9,17};
      int[]       sentenceNumbers = {0};
      int phraseIndex = 0;
     
      HierarchicalPhrases phrases =
View Full Code Here

TOP

Related Classes of joshua.corpus.vocab.SymbolTable

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.