Package org.apache.mahout.common

Examples of org.apache.mahout.common.StringTuple.stringAt()


      // the key is *
      while (reader.next(key, value)) {
        if (weightSum.size() > 1) {
          throw new IOException("Incorrect vocabCount File");
        }
        if (key.stringAt(0).equals(BayesConstants.FEATURE_SET_SIZE)) {
          weightSum.put(BayesConstants.FEATURE_SET_SIZE, value.get());
        }

      }
    }
View Full Code Here


 
  @Override
  protected String generateFileNameForKeyValue(WritableComparable<?> k, Writable v, String name) {
    StringTuple key = (StringTuple) k;
   
    if (key.length() == 1 && key.stringAt(0).equals(BayesConstants.FEATURE_SET_SIZE)) {
      return "trainer-vocabCount/" + name;
    } else {
      return "trainer-tfIdf/" + name;
    }
  }
View Full Code Here

 
  @Override
  protected String generateFileNameForKeyValue(WritableComparable<?> k, Writable v, String name) {
    StringTuple key = (StringTuple) k;
   
    if (key.length() == 1 && key.stringAt(0).equals(BayesConstants.TOTAL_SUM)) {
      return "Sigma_kSigma_j/" + name;
    } else {
      if (key.stringAt(0).equals(BayesConstants.FEATURE_SUM)) {
        return "Sigma_j/" + name;
      } else if (key.stringAt(0).equals(BayesConstants.LABEL_SUM)) {
View Full Code Here

    StringTuple key = (StringTuple) k;
   
    if (key.length() == 1 && key.stringAt(0).equals(BayesConstants.TOTAL_SUM)) {
      return "Sigma_kSigma_j/" + name;
    } else {
      if (key.stringAt(0).equals(BayesConstants.FEATURE_SUM)) {
        return "Sigma_j/" + name;
      } else if (key.stringAt(0).equals(BayesConstants.LABEL_SUM)) {
        return "Sigma_k/" + name;
      } else {
        throw new IllegalArgumentException("Unexpected StringTuple: " + key);
View Full Code Here

    if (key.length() == 1 && key.stringAt(0).equals(BayesConstants.TOTAL_SUM)) {
      return "Sigma_kSigma_j/" + name;
    } else {
      if (key.stringAt(0).equals(BayesConstants.FEATURE_SUM)) {
        return "Sigma_j/" + name;
      } else if (key.stringAt(0).equals(BayesConstants.LABEL_SUM)) {
        return "Sigma_k/" + name;
      } else {
        throw new IllegalArgumentException("Unexpected StringTuple: " + key);
      }
    }
View Full Code Here

    StringTuple tb = (StringTuple) b;
    Preconditions.checkArgument(ta.length() >= 2 && ta.length() <= 3 && tb.length() >= 2 && tb.length() <= 3,
                                "StringTuple length out of bounds");
    // token
    String tmpa = ta.length() == 2 ? ta.stringAt(1) : ta.stringAt(2);
    String tmpb = tb.length() == 2 ? tb.stringAt(1) : tb.stringAt(2);
    int cmp = tmpa.compareTo(tmpb);
    if (cmp != 0) {
      return cmp;
    }
   
View Full Code Here

    StringTuple tb = (StringTuple) b;
    Preconditions.checkArgument(ta.length() >= 2 && ta.length() <= 3 && tb.length() >= 2 && tb.length() <= 3,
                                "StringTuple length out of bounds");
    // token
    String tmpa = ta.length() == 2 ? ta.stringAt(1) : ta.stringAt(2);
    String tmpb = tb.length() == 2 ? tb.stringAt(1) : tb.stringAt(2);
    int cmp = tmpa.compareTo(tmpb);
    if (cmp != 0) {
      return cmp;
    }
   
View Full Code Here

    if (cmp != 0) {
      return cmp;
    }
   
    // type, FEATURE_TF first, then FEATURE_COUNT, then DF or anything else.
    cmp = ta.stringAt(0).compareTo(tb.stringAt(0));
    if (cmp != 0) {
      if (ta.stringAt(0).equals(BayesConstants.FEATURE_TF)) {
        return -1;
      } else if (tb.stringAt(0).equals(BayesConstants.FEATURE_TF)) {
        return 1;
View Full Code Here

    // type, FEATURE_TF first, then FEATURE_COUNT, then DF or anything else.
    cmp = ta.stringAt(0).compareTo(tb.stringAt(0));
    if (cmp != 0) {
      if (ta.stringAt(0).equals(BayesConstants.FEATURE_TF)) {
        return -1;
      } else if (tb.stringAt(0).equals(BayesConstants.FEATURE_TF)) {
        return 1;
      } else if (ta.stringAt(0).equals(BayesConstants.FEATURE_COUNT)) {
        return -1;
      } else if (tb.stringAt(0).equals(BayesConstants.FEATURE_COUNT)) {
        return 1;
View Full Code Here

        return -1;
      } else if (tb.stringAt(0).equals(BayesConstants.FEATURE_TF)) {
        return 1;
      } else if (ta.stringAt(0).equals(BayesConstants.FEATURE_COUNT)) {
        return -1;
      } else if (tb.stringAt(0).equals(BayesConstants.FEATURE_COUNT)) {
        return 1;
      }
      return cmp;
    }
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.