Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*******************************************************************************
* Copyright 2015 - CNRS (Centre National de Recherche Scientifique)
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*******************************************************************************/
package fr.univnantes.lina;
import java.io.PrintStream;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import org.apache.commons.lang3.mutable.MutableInt;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
/**
* The access point-class of all uima-profiler functionalities.
*
* @author Damien Cram
*
*/
public class UIMAProfiler implements ITaskProfiler {
private static boolean activated = false;
private static boolean latexFormat = false;
// private static int skipExamples = 0;
private static int exampleLimit = 5;
private static int overSizeRatio = 5;
private static float addToExampleProba = 0.02f;
public static void setActivated(boolean activated) {
UIMAProfiler.activated = activated;
}
// public static void setSkipExamples(int skipExamples) {
// TaskProfiler.skipExamples = skipExamples;
// }
public static void setExampleLimit(int exampleLimit) {
UIMAProfiler.exampleLimit = exampleLimit;
}
public static void setLatexFormat(boolean latexFormat) {
UIMAProfiler.latexFormat = latexFormat;
}
private static final Map profilers = Maps.newLinkedHashMap();
public static final ITaskProfiler getProfiler(String name) {
if(activated) {
ITaskProfiler profiler = profilers.get(name);
if(profiler != null)
return profiler;
else {
profiler = new UIMAProfiler(name);
profilers.put(name, profiler);
return profiler;
}
} else {
return DoNothingProfiler.getInstance();
}
}
private String name;
private Map pointStatus = Maps.newLinkedHashMap();
private Map counters = Maps.newLinkedHashMap();
private Map> examples = Maps.newHashMap();
private Multimap tasks = LinkedListMultimap.create();
private Map tasksById = Maps.newHashMap();
private UIMAProfiler(String name) {
this.name = name;
}
/* (non-Javadoc)
* @see fr.cnrs.uima.profiler.ITaskProfiler#hit(java.lang.String)
*/
@Override
public void hit(String hitName) {
if(counters.get(hitName) == null)
counters.put(hitName, new MutableInt(1));
else
counters.get(hitName).increment();
}
@Override
public void initHit(String hitName) {
if(counters.get(hitName) == null)
counters.put(hitName, new MutableInt(0));
}
/* (non-Javadoc)
* @see fr.cnrs.uima.profiler.ITaskProfiler#hit(java.lang.String, java.lang.Object)
*/
@Override
public void hit(String hitName, Object example) {
this.hit(hitName);
if(this.examples.get(hitName) == null)
this.examples.put(hitName, new HashSet