Package org.apache.commons.lang.mutable

Examples of org.apache.commons.lang.mutable.MutableInt


     */
    public Map<ScoreType, Double> computeNGramScore()
    {
  Map<ScoreType, Double> results = new HashMap<ScoreType, Double>();

  MutableInt gramHit = new MutableInt(0);
  MutableDouble gramScore = new MutableDouble(0);
  // #------------------------------------------------
  // # read model file and create model n-gram maps
  int totalGramHit = 0;
  int totalGramCount = 0;
  double gramScoreBest = -1;
  double gramScoreP = 0; //# precision
  double gramScoreF = 0; //# f-measure
  int totalGramCountP = 0;

  Map<String, Integer> peer_grams = createNGram(peer, this.n);

  if (DEBUG)
  {
      System.out.println(peer.getSourceFile());
      System.out.println(peer.asText());
      int i = 0;
      System.out.print("[");
      for (String key : peer_grams.keySet())
      {
    System.out.print(key + ":" + peer_grams.get(key).intValue());
    if (i != peer_grams.size() - 1)
    {
        System.out.print("|");
    }
      }
      System.out.println("]");
  }
  for (IRougeSummaryModel model : models)
  {
      Map<String, Integer> model_grams = createNGram(model, this.n);
      if (DEBUG)
      {
    System.out.println(model.getSourceFile());
    System.out.println(model.asText());
    int i = 0;
    System.out.print("[");
    for (String key : model_grams.keySet())
    {
        System.out.print(key + ":" + model_grams.get(key).intValue());
        if (i != model_grams.size() - 1)
        {
      System.out.print("|");
        }
    }
    System.out.println("]");
      }
      ngramScore(model_grams, peer_grams, gramHit, gramScore);

      switch (scoreMode)
      {
    case 'A':
    case 'a':
    {
        totalGramHit += gramHit.intValue();
        totalGramCount += model_grams.get("_cn_");
        totalGramCountP += peer_grams.get("_cn_");
        break;
    }
    case 'B':
    case 'b':
    {
        if (gramScore.doubleValue() > gramScoreBest)
        {
      //# only take a better score (i.e. better match)
      gramScoreBest = gramScore.doubleValue();
      totalGramHit = gramHit.intValue();
      totalGramCount = model_grams.get("_cn_");
      totalGramCountP = peer_grams.get("_cn_");
        }
        break;
    }
    default:
    {
        System.out.println("Warning: Unknown scoring mode - using average mode");
        totalGramHit += gramHit.intValue();
        totalGramCount += model_grams.get("_cn_");
        totalGramCountP += peer_grams.get("_cn_");
    }
      }
  }
View Full Code Here


    }

    ParseContext pc = new ParseContext();

    Map<String, byte[]> files = new HashMap<String, byte[]>();
    MutableInt count = new MutableInt();

    pc.set(EmbeddedDocumentExtractor.class, new MyEmbeddedDocumentExtractor(count, files));

    try {
      parser.parse(is, ch, metadata, pc);
    } catch (TikaException ex) {
      logger.warn(String.format(
              "%s: Unpacker failed",
              info.getPath()
      ), ex);

      throw ex;
    }

    if (count.intValue() == 0 && !saveAll) {
      throw new WebApplicationException(Response.Status.NO_CONTENT);
    }

    if (saveAll) {
      files.put(TEXT_FILENAME, text.toByteArray());
View Full Code Here

    ContentHandler ch = new DefaultHandler();

    ParseContext pc = new ParseContext();

    ZipOutput zout = new ZipOutput();
    MutableInt count = new MutableInt();

    pc.set(EmbeddedDocumentExtractor.class, new MyEmbeddedDocumentExtractor(count, zout));

    try {
      parser.parse(is, ch, metadata, pc);
    } catch (TikaException ex) {
      logger.warn(String.format(
              "%s: Unpacker failed",
              info.getPath()
      ), ex);
    }

    if (count.intValue() == 0) {
      throw new WebApplicationException(Response.Status.NO_CONTENT);
    }

    return zout;
  }
View Full Code Here

    }

    ParseContext pc = new ParseContext();

    Map<String, byte[]> files = new HashMap<String, byte[]>();
    MutableInt count = new MutableInt();

    pc.set(EmbeddedDocumentExtractor.class, new MyEmbeddedDocumentExtractor(count, files));

    try {
      parser.parse(is, ch, metadata, pc);
    } catch (TikaException ex) {
      logger.warn(String.format(
              Locale.ROOT,
              "%s: Unpacker failed",
              info.getPath()
      ), ex);

      throw ex;
    }

    if (count.intValue() == 0 && !saveAll) {
      throw new WebApplicationException(Response.Status.NO_CONTENT);
    }

    if (saveAll) {
      files.put(TEXT_FILENAME, text.toByteArray());
View Full Code Here

    _totalCountBySec = new HashMap<>();
    _successCount = new HashMap<>();
    _failureCount = new HashMap<>();
    _errorCount = new HashMap<>();
    _totalCount = new HashMap<>();
    _successes = new MutableInt(0);
    _failures = new MutableInt(0);
    _errors = new MutableInt(0);
    _total = new MutableInt(0);
   
    _columnReqBySecTypeRowType = ColumnRequirementBySecurityType.getCompositeType();
    _columnReqBySecurityTypeTabularType = ColumnRequirementBySecurityType.getTablularType();
   
    _columnReqRowType = ColumnRequirement.getCompositeType();
View Full Code Here

          }
         
          private <T> void incCount(Map<T, MutableInt> countMap,
                                T key) {
            if (!countMap.containsKey(key)) {
              countMap.put(key, new MutableInt(1));
            } else {
              countMap.get(key).increment();
            }         
          }
        });
View Full Code Here

            generifiedTrainingData.add(instance);
            Serializable classification = instance.getLabel();
            if (classifications.containsKey(classification)) {
                classifications.get(classification).increment();
            } else
                classifications.put(classification, new MutableInt(1));

            if (classifications.size() > 2) {
                binaryClassifications = false;
                return new HashSet<Serializable>(classifications.keySet());
            }
View Full Code Here

TOP

Related Classes of org.apache.commons.lang.mutable.MutableInt

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.