当前位置: 首页>>代码示例>>Java>>正文


Java PrintFile.println方法代码示例

本文整理汇总了Java中edu.stanford.nlp.io.PrintFile.println方法的典型用法代码示例。如果您正苦于以下问题:Java PrintFile.println方法的具体用法?Java PrintFile.println怎么用?Java PrintFile.println使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.stanford.nlp.io.PrintFile的用法示例。


在下文中一共展示了PrintFile.println方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runTraining

import edu.stanford.nlp.io.PrintFile; //导入方法依赖的package包/类
/**
 * Trains a tagger model.
 *
 * @param config Properties giving parameters for the training run
 */
private static void runTraining(TaggerConfig config)
  throws IOException
{
  Date now = new Date();

  System.err.println("## tagger training invoked at " + now + " with arguments:");
  config.dump();
  Timing tim = new Timing();

  PrintFile log = new PrintFile(config.getModel() + ".props");
  log.println("## tagger training invoked at " + now + " with arguments:");
  config.dump(log);
  log.close();

  trainAndSaveModel(config);
  tim.done("Training POS tagger");
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:23,代码来源:MaxentTagger.java

示例2: print

import edu.stanford.nlp.io.PrintFile; //导入方法依赖的package包/类
public void print(String filename) {
  try {
    PrintFile pf = new PrintFile(filename);
    pf.println(" Problem printing ");
    data.print(pf);
    pf.println(" Function printing ");
    for (int i = 0; i < fSize; i++) {
      functions.get(i).print(pf);
    }
  } catch (Exception e) {
    System.out.println("Exception in Problem.print()");
  }
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:14,代码来源:Problem.java

示例3: print

import edu.stanford.nlp.io.PrintFile; //导入方法依赖的package包/类
public void print(PrintFile pf) {
  pf.println(" Experiments : ");
  for (int i = 0; i < size(); i++) {
    pf.println(vArray[i][0] + " : " + vArray[i][1]);
  }
  pf.println(" p(x) ");
  for (int i = 0; i < xSize; i++) {
    pf.println(i + " : " + ptildeX(i));
  }
  pf.println(" p(y) ");
  for (int i = 0; i < ySize; i++) {
    pf.println(i + " : " + ptildeY(i));
  }

}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:16,代码来源:Experiments.java

示例4: save_problem

import edu.stanford.nlp.io.PrintFile; //导入方法依赖的package包/类
/**
 * This method writes the problem data into a file, which is good for reading
 * with MatLab.  It could also have other applications,
 * like reducing the memory requirements
 */

void save_problem(String filename) {
  try {
    PrintFile pf = new PrintFile(filename);
    int N = p.data.xSize;
    int M = p.data.ySize;
    int F = p.fSize;
    // byte[] nl = "\n".getBytes();
    // byte[] dotsp = ". ".getBytes();
    // int space = (int) ' ';
    // write the sizes of X, Y, and F( number of features );
    pf.println(N);
    pf.println(M);
    pf.println(F);
    // save the objective vector like 1.c0, ... ,N*M. cN*M-1
    for (int i = 0; i < N * M; i++) {
      pf.print(i + 1);
      pf.print(". ");
      pf.println(p.data.ptildeX(i / M));
    }// for i

    // save the constraints matrix B
    // for each feature , save its row
    for (int i = 0; i < p.fSize; i++) {
      int[] values = p.functions.get(i).indexedValues;
      for (int k = 0; k < values.length; k++) {
        pf.print(i + 1);
        pf.print(". ");
        pf.print(values[k]);
        pf.print(" ");
        pf.println(1);
      }// k

    }// i

    // save the constraints vector
    // for each feature, save its empirical expectation

    for (int i = 0; i < p.fSize; i++) {
      pf.print(i + 1);
      pf.print(". ");
      pf.println(ftildeArr[i]);
    }// end
    pf.close();

  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:55,代码来源:LambdaSolve.java

示例5: writeTagsAndErrors

import edu.stanford.nlp.io.PrintFile; //导入方法依赖的package包/类
/** Write the tagging and note any errors (if pf != null) and accumulate
 *  global statistics.
 *
 *  @param finalTags Chosen tags for sentence
 *  @param pf File to write tagged output to (can be null, then no output;
 *               at present it is non-null iff the debug property is set)
 */
protected void writeTagsAndErrors(String[] finalTags, PrintFile pf, boolean verboseResults) {
  StringWriter sw = new StringWriter(200);
  for (int i = 0; i < correctTags.length; i++) {
    sw.write(toNice(sent.get(i)));
    sw.write(tagSeparator);
    sw.write(finalTags[i]);
    sw.write(' ');
    if (pf != null) {
      pf.print(toNice(sent.get(i)));
      pf.print(tagSeparator);
      pf.print(finalTags[i]);
    }
    if ((correctTags[i]).equals(finalTags[i])) {
      numRight++;
    } else {
      numWrong++;
      if (pf != null) pf.print('|' + correctTags[i]);
      if (verboseResults) {
        EncodingPrintWriter.err.println((maxentTagger.dict.isUnknown(sent.get(i)) ? "Unk" : "") + "Word: " + sent.get(i) + "; correct: " + correctTags[i] + "; guessed: " + finalTags[i], encoding);
      }

      if (maxentTagger.dict.isUnknown(sent.get(i))) {
        numWrongUnknown++;
        if (pf != null) pf.print("*");
      }// if
    }// else
    if (pf != null) pf.print(' ');
  }// for
  if (pf != null) pf.println();

  if (verboseResults) {
    PrintWriter pw;
    try {
      pw = new PrintWriter(new OutputStreamWriter(System.out, encoding), true);
    } catch (UnsupportedEncodingException uee) {
      pw = new PrintWriter(new OutputStreamWriter(System.out), true);
    }
    pw.println(sw);
  }
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:48,代码来源:TestSentence.java

示例6: printUnknown

import edu.stanford.nlp.io.PrintFile; //导入方法依赖的package包/类
/**
 * This method should be called after the sentence has been tagged.
 * For every unknown word, this method prints the 3 most probable tags
 * to the file pfu.
 *
 * @param numSent The sentence number
 * @param pfu The file to print the probable tags to
 */
void printUnknown(int numSent, PrintFile pfu) {
  NumberFormat nf = new DecimalFormat("0.0000");
  int numTags = maxentTagger.tags.getSize();
  double[][][] probabilities = new double[size][kBestSize][numTags];
  calculateProbs(probabilities);
  for (int current = 0; current < size; current++) {
    if (maxentTagger.dict.isUnknown(sent.get(current))) {
      pfu.print(sent.get(current));
      pfu.print(':');
      pfu.print(numSent);
      double[] probs = new double[3];
      String[] tag3 = new String[3];
      getTop3(probabilities, current, probs, tag3);
      for (int i = 0; i < 3; i++) {
        if (probs[i] > Double.NEGATIVE_INFINITY) {
          pfu.print('\t');
          pfu.print(tag3[i]);
          pfu.print(' ');
          pfu.print(nf.format(Math.exp(probs[i])));
        }
      }
      int rank;
      String correctTag = toNice(this.correctTags[current]);
      for (rank = 0; rank < 3; rank++) {
        if (correctTag.equals(tag3[rank])) {
          break;
        } //if
      }
      pfu.print('\t');
      switch (rank) {
        case 0:
          pfu.print("Correct");
          break;
        case 1:
          pfu.print("2nd");
          break;
        case 2:
          pfu.print("3rd");
          break;
        default:
          pfu.print("Not top 3");
      }
      pfu.println();
    }// if
  }// for
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:55,代码来源:TestSentence.java

示例7: printTop

import edu.stanford.nlp.io.PrintFile; //导入方法依赖的package包/类
void printTop(PrintFile pfu) {
  NumberFormat nf = new DecimalFormat("0.0000");
  int numTags = maxentTagger.tags.getSize();
  double[][][] probabilities = new double[size][kBestSize][numTags];
  calculateProbs(probabilities);
  for (int current = 0; current < size; current++) {
    pfu.print(sent.get(current));
    double[] probs = new double[3];
    String[] tag3 = new String[3];
    getTop3(probabilities, current, probs, tag3);
    for (int i = 0; i < 3; i++) {
      if (probs[i] > Double.NEGATIVE_INFINITY) {
        pfu.print('\t');
        pfu.print(tag3[i]);
        pfu.print(' ');
        pfu.print(nf.format(Math.exp(probs[i])));
      }
    }
    int rank;
    String correctTag = toNice(this.correctTags[current]);
    for (rank = 0; rank < 3; rank++) {
      if (correctTag.equals(tag3[rank])) {
        break;
      } //if
    }
    pfu.print('\t');
    switch (rank) {
    case 0:
      pfu.print("Correct");
      break;
    case 1:
      pfu.print("2nd");
      break;
    case 2:
      pfu.print("3rd");
      break;
    default:
      pfu.print("Not top 3");
    }
    pfu.println();
  } // for
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:43,代码来源:TestSentence.java


注:本文中的edu.stanford.nlp.io.PrintFile.println方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。