Package org.apache.commons.lang.mutable

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



  // --- Get sets of terms

  static public void update(Map<String, MutableInt> terms, String word) {
    MutableInt v = terms.get(word);
    if (v == null)
      v = terms.put(word, new MutableInt(1));
    else
      v.add(1);

  }
View Full Code Here


    }

    void train(List<String> words) {
      numDocuments++;
      for (String word : words) {
        MutableInt i = features.get(word);
        if (i == null) {
          i = new MutableInt(0);
          features.put(word, i);
        }
        i.increment();
      }
    }
View Full Code Here

      categoryProbability = (double) numDocuments /
          (double) totalDocuments;
    }

    double weightedProbability(String word) {
      MutableInt i = features.get(word);
      return (i == null ? 0.1 : (i.doubleValue() /
          (double) numDocuments));
    }
View Full Code Here

            _Float = new Float( 42f );
            _Short = Short.valueOf( (short) 42 );
            _BigDecimal = new BigDecimal( 42 );
            _AtomicInteger = new AtomicInteger( 42 );
            _AtomicLong = new AtomicLong( 42 );
            _MutableInt = new MutableInt( 42 );
            _IntegerArray = new Integer[] { 42 };
            _Date = new Date( System.currentTimeMillis() - 10000 );
            _Calendar = Calendar.getInstance();
            _Currency = Currency.getInstance( "EUR" );
            _ArrayList = new ArrayList<String>( Arrays.asList( "foo" ) );
View Full Code Here

            _Float = Float.valueOf( 42f );
            _Short = Short.valueOf( (short) 42 );
            _BigDecimal = new BigDecimal( 42 );
            _AtomicInteger = new AtomicInteger( 42 );
            _AtomicLong = new AtomicLong( 42 );
            _MutableInt = new MutableInt( 42 );
            _IntegerArray = new Integer[] { 42 };
            _Date = new Date( System.currentTimeMillis() - 10000 );
            _Calendar = Calendar.getInstance();
            _Currency = Currency.getInstance( "EUR" );
            _ArrayList = new ArrayList<String>( Arrays.asList( "foo" ) );
View Full Code Here

                { Float.class, Float.valueOf( 42f ) },
                { Short.class, Short.valueOf( (short) 42 ) },
                { BigDecimal.class, new BigDecimal( 42 ) },
                { AtomicInteger.class, new AtomicInteger( 42 ) },
                { AtomicLong.class, new AtomicLong( 42 ) },
                { MutableInt.class, new MutableInt( 42 ) },
                { Integer[].class, new Integer[] { 42 } },
                { Date.class, new Date( System.currentTimeMillis() - 10000 ) },
                { Calendar.class, Calendar.getInstance() },
                { Currency.class, Currency.getInstance( "EUR" ) },
                { ArrayList.class, new ArrayList<String>( Arrays.asList( "foo" ) ) },
View Full Code Here


        // Create a pool of executing threads.
        final int totalRounds = settings.getTotalRounds();
        final CountDownLatch latch = new CountDownLatch(1);
        final MutableInt rounds = new MutableInt(totalRounds);
        final Callable<Long> benchmarkRunner = createBenchmarkRunner();
        final Thread [] pool = createBenchmarkThreads(latch, rounds, monitor, benchmarkRunner);

        // Start all benchmark threads at once and wait for all of them to finish.
        monitor.beginTask("Running...", totalRounds);
View Full Code Here

                { Float.class, new Float( 42f ) },
                { Short.class, new Short( (short) 42 ) },
                { BigDecimal.class, new BigDecimal( 42 ) },
                { AtomicInteger.class, new AtomicInteger( 42 ) },
                { AtomicLong.class, new AtomicLong( 42 ) },
                { MutableInt.class, new MutableInt( 42 ) },
                { Integer[].class, new Integer[] { 42 } },
                { Date.class, new Date( System.currentTimeMillis() - 10000 ) },
                { Calendar.class, Calendar.getInstance() },
                { Currency.class, Currency.getInstance( "EUR" ) },
                { ArrayList.class, new ArrayList<String>( Arrays.asList( "foo" ) ) },
View Full Code Here

            _Float = new Float( 7f );
            _Short = new Short( (short) 8 );
            _BigDecimal = new BigDecimal( 9 );
            _AtomicInteger = new AtomicInteger( 10 );
            _AtomicLong = new AtomicLong( 11 );
            _MutableInt = new MutableInt( 12 );
            _IntegerArray = new Integer[] { 13 };
            _Date = new Date( System.currentTimeMillis() - 10000 );
            _Calendar = Calendar.getInstance();
            _Currency = Currency.getInstance( "EUR" );
            _ArrayList = new ArrayList<String>( Arrays.asList( "foo" ) );
View Full Code Here

     */
    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

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.