Package joshua.corpus.alignment

Examples of joshua.corpus.alignment.AlignmentGrids


        alignmentsPrintStream.println(sentence);
      }
      alignmentsPrintStream.close();
      String alignmentFileName = alignmentsFile.getAbsolutePath();
     
      AlignmentGrids grids = new AlignmentGrids(
          new Scanner(alignmentsFile),
          sourceCorpus,
          targetCorpus,
          numberOfSentences);
   
View Full Code Here


    if ("AlignmentArray".equals(alignmentsType)) {
      if (logger.isLoggable(Level.INFO)) logger.info("Using AlignmentArray");
      alignments = SuffixArrayFactory.createAlignments(alignmentsFileName, sourceSuffixArray, targetSuffixArray);
    } else if ("AlignmentGrids".equals(alignmentsType) || "AlignmentsGrid".equals(alignmentsType)) {
      if (logger.isLoggable(Level.INFO)) logger.info("Using AlignmentGrids");
      alignments = new AlignmentGrids(new Scanner(new File(alignmentsFileName)), sourceCorpusArray, targetCorpusArray, trainingSize, requireTightSpans);
    } else if ("MemoryMappedAlignmentGrids".equals(alignmentsType)) {
      if (logger.isLoggable(Level.INFO)) logger.info("Using MemoryMappedAlignmentGrids");
      alignments = new MemoryMappedAlignmentGrids(alignmentsFileName, sourceCorpusArray, targetCorpusArray);
    } else {
      alignments = null;
View Full Code Here

    Corpus targetCorpusArray = SuffixArrayFactory.createCorpusArray(targetFileName, targetVocab, numTargetWords, numTargetSentences);
    Suffixes targetSuffixArray = SuffixArrayFactory.createSuffixArray(targetCorpusArray, maxCacheSize);
   
    int trainingSize = sourceCorpusArray.getNumSentences();
    boolean requireTightSpans = true;
    Alignments alignments = new AlignmentGrids(new Scanner(new File(alignmentFileName)), sourceCorpusArray, targetCorpusArray, trainingSize, requireTightSpans);
   
//    ParallelCorpus parallelCorpus =
//      new AlignedParallelCorpus(sourceCorpusArray, targetCorpusArray, alignments);
   
//    LexicalProbabilities lexProbs =
View Full Code Here

        out.println("Target language corpus: " + binaryTargetCorpusFilename);
    }
   
    {
      // Construct alignments data structure
      AlignmentGrids grids = new AlignmentGrids(
          new Scanner(new File(alignmentsFileName)),
          sourceCorpusArray,
          targetCorpusArray,
          numberOfSentences);

      // Write alignments to disk
      {
        String binaryAlignmentsFilename = outputDirName + File.separator + "alignment.grids";
        if (logger.isLoggable(Level.INFO)) logger.info("Writing binary alignment grids to disk at " + binaryAlignmentsFilename);

        BinaryOut alignmentsOut = new BinaryOut(binaryAlignmentsFilename);
        grids.writeExternal(alignmentsOut);
        alignmentsOut.flush();
        alignmentsOut.close();

        out.println("Source-target alignment grids: " + binaryAlignmentsFilename);
      }
View Full Code Here

      SuffixArray sourceSuffixArray =
        SuffixArrayFactory.createSuffixArray(sourceCorpusArray, SuffixArray.DEFAULT_CACHE_CAPACITY);
      alignments =
        SuffixArrayFactory.createAlignments(alignmentFileName, sourceSuffixArray, targetSuffixArray);
    } else if (alignmentsType.equals("AlignmentGrids")) {
      alignments = new AlignmentGrids(new Scanner(new File(alignmentFileName)), sourceCorpusArray, targetCorpusArray, 3);     
    } else if (alignmentsType.equals("MemoryMappedAlignmentGrids")) {
      AlignmentGrids grids = new AlignmentGrids(new Scanner(new File(alignmentFileName)), sourceCorpusArray, targetCorpusArray, 3);
     
      File mmAlignmentFile = File.createTempFile("memoryMappedAlignment", new Date().toString());
      ObjectOutput out = new BinaryOut(mmAlignmentFile);
      grids.writeExternal(out);
      out.flush();
      out.close();
     
      alignments = new MemoryMappedAlignmentGrids(mmAlignmentFile.getAbsolutePath(), sourceCorpusArray, targetCorpusArray);
    } else {
View Full Code Here

TOP

Related Classes of joshua.corpus.alignment.AlignmentGrids

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.