Package edu.stanford.nlp.io

Examples of edu.stanford.nlp.io.InDataStreamFile


  /** Currently unused */
  @SuppressWarnings("unused")
  private void read(String filename) {
    try {
      InDataStreamFile rF = new InDataStreamFile(filename);
      xSize = rF.readInt();
      ySize = rF.readInt();
      int number = rF.readInt();
      px = new int[xSize];
      py = new int[ySize];
      pxy = new int[xSize][ySize];
      for (int i = 0; i < xSize; i++) {
        px[i] = rF.readInt();
      }
      for (int j = 0; j < ySize; j++) {
        py[j] = rF.readInt();
      }
      for (int i = 0; i < xSize; i++) {
        for (int j = 0; j < dim; j++) {
          pxy[i][j] = rF.readInt();
        }
      }
      rF.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here


   * @param config tagger configuration file
   * @return true (whether this operation succeeded; always true
   * @throws Exception ??
   */
  protected static boolean convertMultifileTagger(String filename, String newFilename, TaggerConfig config) throws Exception {
    InDataStreamFile rf = new InDataStreamFile(filename);
    GlobalHolder.init(config);
    if (VERBOSE) {
      System.err.println(" length of holder " + new File(filename).length());
    }

    xSize = rf.readInt();
    ySize = rf.readInt();
    dict.read(filename + ".dict");

    if (VERBOSE) {
      System.err.println(" dictionary read ");
    }
    tags.read(filename + ".tags");
    readExtractors(filename + ".ex");

    dict.setAmbClasses();

    int[] numFA = new int[extractors.getSize() + extractorsRare.getSize()];
    int sizeAssoc = rf.readInt();
    PrintFile pfVP = null;
    if (VERBOSE) {
      pfVP = new PrintFile("pairs.txt");
    }
    for (int i = 0; i < sizeAssoc; i++) {
      int numF = rf.readInt();
      FeatureKey fK = new FeatureKey();
      fK.read(rf);
      numFA[fK.num]++;
      fAssociations.put(fK, numF);
    }

    if (VERBOSE) {
      pfVP.close();
    }
    if (VERBOSE) {
      for (int k = 0; k < numFA.length; k++) {
        System.err.println(" Number of features of kind " + k + ' ' + numFA[k]);
      }
    }
    prob = new LambdaSolveTagger(filename + ".prob");
    if (VERBOSE) {
      System.err.println(" prob read ");
    }

    saveModel(newFilename, config);
    rf.close();
    return true;
  }
View Full Code Here

  }

  @Override
  public void read(String filename) {
    try {
      InDataStreamFile rF = new InDataStreamFile(filename);
      int len = rF.readInt();
      xIndexed = new int[len];
      for (int i = 0; i < xIndexed.length; i++) {
        xIndexed[i] = rF.readInt();
      }
      int numFeats = rF.readInt();
      for (int i = 0; i < numFeats; i++) {
        TaggerFeature tF = new TaggerFeature();
        tF.read(rF);
        this.add(tF);
      }
      rF.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

  }


  public void read(String filename) {
    try {
      InDataStreamFile rF = new InDataStreamFile(filename);
      int numFeats = rF.readInt();
      for (int i = 0; i < numFeats; i++) {
        Feature tF = new Feature();
        tF.read(rF);
        this.add(tF);
      }
View Full Code Here

  }


  protected void read(String filename) {
    try {
      InDataStreamFile in = new InDataStreamFile(filename);
      read(in);
      in.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

   *
   * @param filename The file to read from
   */
  public void readL(String filename) {
    try {
      InDataStreamFile rf = new InDataStreamFile(filename);
      lambda = read_lambdas(rf);
      rf.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

   * @param modelFilename A filename. It will be read and closed
   * @return An array of lambda values read from the file.
   */
  static double[] read_lambdas(String modelFilename) {
    try {
      InDataStreamFile rf = new InDataStreamFile(modelFilename);
      double[] lamb = read_lambdas(rf);
      rf.close();
      return lamb;
    } catch (IOException e) {
      e.printStackTrace();
    }
    return null;
View Full Code Here

    }
  }

  protected void read(String filename) {
    try {
      InDataStreamFile rf = new InDataStreamFile(filename);
      read(rf, filename);

      int len1 = rf.readInt();
      for (int i = 0; i < len1; i++) {
        int iO = rf.readInt();
        CountWrapper tC = new CountWrapper();
        tC.read(rf);

        this.partTakingVerbs.put(iO, tC);
      }
      rf.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.io.InDataStreamFile

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.