public static void main(String[] args) throws IOException {

    //		String fileInputReq = args[0];
    //		float bid_price = Float.valueOf(args[1]);
    //		String model_para = args[2];
    //		String fileOutReq = args[3];

    String fileInputReq = "test.txt";
    String str = "0.150000000";
    float bid_price = Float.parseFloat(str);
    System.out.println(bid_price);
    String dict = "dict";
    String model_para = "train.model";
    String resultsOut = "results.txt";

    TestDataGen2 saj = new TestDataGen2();
    long startTime = System.currentTimeMillis();
    String ReqLine = saj.dataMergeReq(fileInputReq, bid_price);
    //						System.out.println(ReqLine);
    String cutdic = saj.MakeDict(ReqLine);
    //						System.out.println(cutdic);
    //		String ReqLineFormat = saj.dictGet(cutdic,dict);
    String outputs = "result.txt";
    saj.dictGet(cutdic, dict, outputs);
    //		System.out.println(ReqLineFormat);

    String[] arg = {"-b", "1", outputs, model_para, resultsOut};
    Predict.main(arg);

    long endTime = System.currentTimeMillis();
    long trainTime = endTime - startTime;
    System.out.println(trainTime + "ms\n");
  }
示例#2
0
  public static void RetrieveTrainMatrix() {
    try {
      BufferedReader flrdr =
          new BufferedReader(
              new FileReader("D:\\IR\\Assignment7\\Pytest\\part2\\output\\train_matrix.txt"));
      String line = "";
      int doc_count = 0;

      while ((line = flrdr.readLine()) != null) {
        SortedSet<Integer> word_ids = new TreeSet<Integer>();
        int val_count = 0;

        String[] key_value = line.split(" :: ");
        key_value[1] = key_value[1].substring(1, key_value[1].length() - 2);
        String[] values = key_value[1].split(",");

        FeatureNode[] node = new FeatureNode[values.length];

        for (String val : values) word_ids.add(Integer.parseInt(val.trim()));

        for (int val : word_ids) node[val_count++] = new FeatureNode(val, 1);

        if (spam_docs.contains(key_value[0].trim())) ylable[doc_count] = 1;
        else ylable[doc_count] = 0;

        train_matrix[doc_count++] = node;
      }
      flrdr.close();
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(0);
    }
  }
  ABSAClassifierHotels(int option, String trainFile, String testFile, String ddgFile)
      throws IOException {

    rootDirectory = System.getProperty("user.dir");
    mainClassifierFunction(option, trainFile, testFile, ddgFile);

    // rootDirectory = "D:\\Course\\Semester VII\\Internship\\sentiment\\indian";
    // return generateFeature();
  }
示例#4
0
  public static void RetrieveTestMatrix() {
    try {
      BufferedReader flrdr =
          new BufferedReader(
              new FileReader("D:\\IR\\Assignment7\\Pytest\\part2\\output\\test_matrix.txt"));
      String line = "";

      while ((line = flrdr.readLine()) != null) {
        SortedSet<Integer> word_ids = new TreeSet<Integer>();
        int val_count = 0;

        String[] key_value = line.split(" :: ");

        if (key_value[1].trim().length() < 1)
          System.out.println("Error on Train Doc " + key_value[0]);

        key_value[1] = key_value[1].substring(1, key_value[1].length() - 2);
        String[] values = key_value[1].split(",");

        FeatureNode[] node = new FeatureNode[values.length];

        for (String val : values) word_ids.add(Integer.parseInt(val.trim()));

        for (int val : word_ids) node[val_count++] = new FeatureNode(val, 1);

        double predict = Linear.predict(model, node);
        doc_score.put(key_value[0].trim(), predict);
      }

      flrdr.close();

    } catch (Exception e) {
      e.printStackTrace();
      System.exit(0);
    }
  }