Examples of WeightingMethod


Examples of com.digitalpebble.classification.Parameters.WeightingMethod

    int fieldNum = this.indexToField[pos];
    double frequency = occurences / tokensPerField[fieldNum];

    // is there a custom weight for this field?
    String fieldName = lexicon.getFields()[fieldNum];
    WeightingMethod method = lexicon.getMethod(fieldName);

    if (method.equals(Parameters.WeightingMethod.BOOLEAN)) {
      score = 1;
    } else if (method.equals(Parameters.WeightingMethod.OCCURRENCES)) {
      score = occurences;
    } else if (method.equals(Parameters.WeightingMethod.FREQUENCY)) {
      score = frequency;
    } else if (method.equals(Parameters.WeightingMethod.TFIDF)) {
      int df = lexicon.getDocFreq(indexTerm);
      double idf = numdocs / (double) df;
      score = frequency * Math.log(idf);
      if (idf == 1)
        score = frequency;
View Full Code Here

Examples of com.digitalpebble.classification.Parameters.WeightingMethod

        // load the lexicon and the raw file
        Lexicon lexicon = new Lexicon(lexiconF);

        String weightingScheme = props.getProperty(
                "classification_weight_scheme", "tfidf");
        WeightingMethod method = WeightingMethod
                .methodFromString(weightingScheme);
        lexicon.setMethod(method);

        // get the raw file
        FileTrainingCorpus ftc = new FileTrainingCorpus(new File(raw));
View Full Code Here

Examples of com.digitalpebble.classification.Parameters.WeightingMethod

    int fieldNum = this.indexToField[pos];
    double frequency = occurences / tokensPerField[fieldNum];

    // is there a custom weight for this field?
    String fieldName = lexicon.getFields()[fieldNum];
    WeightingMethod method = lexicon.getMethod(fieldName);

    if (method.equals(Parameters.WeightingMethod.BOOLEAN)) {
      score = 1;
    } else if (method.equals(Parameters.WeightingMethod.OCCURRENCES)) {
      score = occurences;
    } else if (method.equals(Parameters.WeightingMethod.FREQUENCY)) {
      score = frequency;
    } else if (method.equals(Parameters.WeightingMethod.TFIDF)) {
      int df = lexicon.getDocFreq(indexTerm);
      double idf = numdocs / (double) df;
      score = frequency * Math.log(idf);
      if (idf == 1)
        score = frequency;
View Full Code Here

Examples of com.digitalpebble.classification.Parameters.WeightingMethod

  /**
   * Returns the weighting scheme used for a specific field or the default one
   * if nothing has been specified for it
   **/
  public WeightingMethod getMethod(String fieldName) {
    WeightingMethod method = this.customWeights.get(fieldName);
    if (method != null)
      return method;
    return this.method_used;
  }
View Full Code Here

Examples of com.digitalpebble.classification.Parameters.WeightingMethod

    this.method_used = method;
  }

  /** Sets the weighting scheme for a specific field **/
  public void setMethod(WeightingMethod method, String fieldName) {
    WeightingMethod existingmethod = this.customWeights.get(fieldName);
    if (existingmethod == null) {
      this.customWeights.put(fieldName, method);
      return;
    }
    // already one specified : check that it is the same as the one we have
    if (!method.equals(existingmethod))
      throw new RuntimeException("Already set weight of field "
          + fieldName + " to " + existingmethod.toString());
  }
View Full Code Here

Examples of com.digitalpebble.classification.Parameters.WeightingMethod

    for (String f : tmp) {
      // see if there is a custom weight for it
      String[] fieldTokens = f.split(":");
      String field_name = fieldTokens[0];
      if (fieldTokens.length > 1) {
        WeightingMethod method = Parameters.WeightingMethod
            .methodFromString(fieldTokens[1]);
        customWeights.put(field_name, method);
      }
      getFieldID(field_name, true);
    }
View Full Code Here

Examples of com.digitalpebble.classification.Parameters.WeightingMethod

    }
    writer.write("\n");
    // save the field names (possibly with non default scheme)
    for (String fname : this.getFields()) {
      writer.write(fname);
      WeightingMethod method = customWeights.get(fname);
      if (method != null)
        writer.write(":" + method.name());
      writer.write(" ");
    }
    writer.write("\n");

    // dump all token_forms one by one
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.