Examples of Phrase


Examples of edu.umd.hooka.Phrase

    at.normalize();
    // System.out.println(at);
    int[] fw = {2, 1, 2, 3};
    //int[] fw = {2, 1, 2};
    int[] ew = {1, 2, 1};
    Phrase f = new Phrase(fw, 1);
    Phrase e = new Phrase(ew, 1);
    PhrasePair pp = new PhrasePair(f, e);
    hmm = new HMM(tt, at);
    hmm.buildHMMTables(pp);
    hmm.baumWelch(pp, null);
    TTable_monolithic tc = (TTable_monolithic)tt.clone(); tc.clear();
    ATable ac = (ATable)at.clone(); ac.clear();
    hmm.addPartialTranslationCountsToTTable(tc);
    hmm.addPartialJumpCountsToATable(ac);
    System.out.println("COUNTS:\n" + tc);
    tc.normalize();
    ac.normalize();
    System.out.println("OLD:\n" + at);
    System.out.println("NEW:\n" + ac);
    System.out.println("\nnew:\n"+tc);
    //if (true) return;
    PerplexityReporter cr = new PerplexityReporter();
    Alignment a = hmm.viterbiAlign(pp, cr);
    double ce1 = cr.getCrossEntropy();
    System.out.println(a.toStringVisual() + "\n"+cr);
    assertTrue(a.aligned(0, 0));
    System.out.println(hmm.backtrace);
    hmm = new HMM(tc, ac);
    hmm.buildHMMTables(pp);
    cr.reset();
    a = hmm.viterbiAlign(pp, cr);
    double ce2 = cr.getCrossEntropy();
    // perplexity should decrease!
    assertTrue(ce1 > ce2);
    assert(tc.get(1,1) > 0.0f);
    System.out.println(a.toStringVisual() + "\n" + cr + "\nPG::\n" + hmm.computeAlignmentPosteriors(pp));
    assertEquals(a.getELength(), e.size());
    assertEquals(a.getFLength(), f.size());
  }
View Full Code Here

Examples of jm.music.data.Phrase

    private int[] secondChords = new int[0];
    private String[] chordStrings = {"I", "II", "III", "IV", "V", "VI", "VII",
            "."};

    public JGrandStave() {
        this(new Phrase());
        bPos = 110;
        panelHeight = 310;
        this.setSize((int) (beatWidth * 40), panelHeight);
    }
View Full Code Here

Examples of joshua.corpus.Phrase

        return null != this.nextForeignPhrase;
      }
     
      public PhrasePair next() {
        if (this.hasNext()) {
          Phrase f = this.nextForeignPhrase;
         
          Phrase e = null;
          try {
            e = re.readPhrase();
          } catch (IOException ioe) {
            throw new RuntimeException("IOException", ioe);
          }
          if (null == e) {
            fileLengthMismatchException();
            return null; // Needed to make javac happy
          } else {
            if (e.size() != 0 && f.size() != 0) {
              if (null != ra) {
                String line = null;
                try {
                  line = ra.readLine();
                } catch (IOException ioe) {
                  throw new RuntimeException("IOException", ioe);
                }
               
                if (null == line) {
                  fileLengthMismatchException();
                  return null; // Needed to make javac happy
                } else {
                  Alignment a = new Alignment(
                    (short)f.size(), (short)e.size(), line);
                 
                  this.nextForeignPhrase = null;
                  return new PhrasePair(f, e, a);
                }
              } else {
View Full Code Here

Examples of kpi.asoiu.model.Phrase

        types.put(PartsOfSentence.PREDICATE, predicateTypes);

    }

    public Phrase parse(Parse parse, PartsOfSentence partsOfSentence) {
        Phrase phrase = new Phrase();
        collect(parse, phrase, partsOfSentence);
//        System.out.println("!!! phrase = " + phrase);
        return phrase;
    }
View Full Code Here

Examples of net.nutch.searcher.Query.Phrase

        String[] opt = CommonGrams.optimizePhrase(c.getPhrase(), field);
        if (opt.length==1) {
          c = new Clause(new Query.Term(opt[0]),
                         c.isRequired(), c.isProhibited());
        } else {
          c = new Clause(new Phrase(opt), c.isRequired(), c.isProhibited());
        }
      }

      // construct appropriate Lucene clause
      org.apache.lucene.search.Query luceneClause;
      if (c.isPhrase()) {
        Phrase nutchPhrase = c.getPhrase();
        Query.Term[] terms = nutchPhrase.getTerms();
        PhraseQuery lucenePhrase = new PhraseQuery();
        for (int j = 0; j < terms.length; j++) {
          lucenePhrase.add(new Term(field, terms[j].toString()));
        }
        luceneClause = lucenePhrase;
View Full Code Here

Examples of net.sf.nlpshell.domain.phrase.Phrase

      sentence.children.addAll(parts);
      partOfSpeech = sentence;
    }

    if (Phrase.PennTreeBankPhraseTagset.literals().contains(type)) {
      Phrase phrase = Phrase.newPhraseInstance(type, parse.toString());
      List<PartOfSpeech> parts = new ArrayList<PartOfSpeech>();
      for (Parse parseChild : parse.getChildren()) {
        parts.add(buildPOS(parseChild));
      }
      phrase.children.addAll(parts);
View Full Code Here

Examples of opennlp.ccg.alignment.Phrase

                    Status.forAbbreviation(a.getAttribute("status"))));
          }
        }
      }
     
      Alignment a = new Alignment(new Phrase(id,
            Alignments.tokenize(first.getElementsByTagName("string").item(0).getTextContent())),
              new Phrase(id,
                Alignments.tokenize(second.getElementsByTagName("string").item(0).getTextContent())),
            ms);
     
      Element firstLF = (Element)first.getElementsByTagName("lf").item(0),
          secondLF = (Element)second.getElementsByTagName("lf").item(0);
View Full Code Here

Examples of org.apache.nutch.searcher.Query.Phrase

    PositionIncrementAttribute pia = ts.getAttribute(PositionIncrementAttribute.class);
    while (ts.incrementToken()) {
      System.out.println("Token: " + ta.term() + " offs:" + oa.startOffset() + "-" + oa.endOffset()
          + " incr: " + pia.getPositionIncrement());
    }
    String[] optimized = commonGrams.optimizePhrase(new Phrase(args), "url");
    System.out.print("Optimized: ");
    for (int i = 0; i < optimized.length; i++) {
      System.out.print(optimized[i] + " ");
    }
    System.out.println();
View Full Code Here

Examples of org.woped.pnml.TextType.Phrase

        textType = iNet.addNewText();
       
        //write every row of the table to the file
        for(int i = 0; i < tableSize; i++){
          String[] row = elementContainer.getParaphrasingModel().getElementByRow(i);
          Phrase phrase = textType.addNewPhrase();
          phrase.setIds(row[0].trim());
          phrase.setStringValue(row[1].trim());
          LoggerManager.debug(Constants.FILE_LOGGER, "   ... Description (ID:" + row[0] + ") set");

        }       
      }
    }
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.