List of usage examples for com.google.common.collect HashMultiset create
public static <E> HashMultiset<E> create()
From source file:org.datacleaner.components.machinelearning.impl.VectorNGramFeatureModifierBuilder.java
public VectorNGramFeatureModifierBuilder(MLTrainingConstraints constraints, int gramLength) { this.gramLength = gramLength; this.constraints = constraints; this.grams = HashMultiset.create(); }
From source file:com.sonarsource.lits.Dump.java
static void load(File file, Map<String, Multiset<IssueKey>> result) { JSONObject json;/*w w w . j a v a 2s . c om*/ try (FileInputStream fis = new FileInputStream(file); InputStreamReader in = new InputStreamReader(fis, StandardCharsets.UTF_8)) { json = (JSONObject) JSONValue.parse(in); } catch (IOException e) { throw Throwables.propagate(e); } String ruleKey = ruleKeyFromFileName(file.getName()); for (Map.Entry<String, Object> component : json.entrySet()) { String componentKey = component.getKey(); Multiset<IssueKey> issues = result.get(componentKey); if (issues == null) { issues = HashMultiset.create(); result.put(componentKey, issues); } JSONArray lines = (JSONArray) component.getValue(); for (Object line : lines) { issues.add(new IssueKey(componentKey, ruleKey, (Integer) line)); } } }
From source file:org.sonar.graph.FeedbackCycle.java
private static Multiset<Edge> createBagWithAllEdgesOfCycles(Set<Cycle> cycles) { Multiset<Edge> edgesBag = HashMultiset.create(); for (Cycle cycle : cycles) { for (Edge edge : cycle.getEdges()) { edgesBag.add(edge);/*from ww w . j a va2 s . co m*/ } } return edgesBag; }
From source file:com.continuuity.loom.layout.ClusterLayout.java
public ClusterLayout(Constraints constraints, Multiset<NodeLayout> layout) { this.constraints = constraints; this.layout = ImmutableMultiset.copyOf(layout); this.serviceCounts = HashMultiset.create(); for (Multiset.Entry<NodeLayout> entry : layout.entrySet()) { for (String service : entry.getElement().getServiceNames()) { serviceCounts.add(service, entry.getCount()); }//from w w w . java 2 s. c o m } }
From source file:com.github.nmorel.gwtjackson.guava.client.deser.HashMultisetJsonDeserializer.java
@Override protected HashMultiset<T> newCollection() { return HashMultiset.create(); }
From source file:de.isabeldrostfromm.sof.Trainer.java
@Override public OnlineLogisticRegression train(ExampleProvider provider) { OnlineLogisticRegression logReg = new OnlineLogisticRegression(ModelTargets.STATEVALUES.length, Vectoriser.getCardinality(), new L1()); Multiset<String> set = HashMultiset.create(); for (Example instance : provider) { set.add(instance.getState());/*from w w w.j ava 2s.c om*/ logReg.train(ModelTargets.STATES.get(instance.getState()), instance.getVector()); } return logReg; }
From source file:edu.washington.cs.cupid.standard.MostFrequent.java
@Override public LinearJob<List<V>, V> getJob(final List<V> input) { return new LinearJob<List<V>, V>(this, input) { @Override// w w w. ja va 2 s . c om protected LinearStatus<V> run(final IProgressMonitor monitor) { try { monitor.beginTask(getName(), 100); Multiset<V> set = HashMultiset.create(); set.addAll(input); for (V val : Multisets.copyHighestCountFirst(set)) { return LinearStatus.makeOk(getCapability(), val); } return LinearStatus.<V>makeError( new IllegalArgumentException("Cannot get most frequent element of empty collection")); } catch (Exception ex) { return LinearStatus.<V>makeError(ex); } finally { monitor.done(); } } }; }
From source file:org.apache.mahout.vectorizer.encoders.TextValueEncoder.java
public TextValueEncoder(String name) { super(name, 2); wordEncoder = new StaticWordValueEncoder(name); counts = HashMultiset.create(); }
From source file:co.cask.cdap.etl.planner.ControlDag.java
public ControlDag(Collection<Connection> connections) { super(connections); this.nodeVisits = HashMultiset.create(); }
From source file:org.opentripplanner.routing.spt.MultiStateShortestPathTree.java
public void dump() { Multiset<Integer> histogram = HashMultiset.create(); int statesCount = 0; int maxSize = 0; for (Map.Entry<Vertex, List<State>> kv : stateSets.entrySet()) { List<State> states = kv.getValue(); int size = states.size(); histogram.add(size);//from w w w .ja v a 2s . c o m statesCount += size; if (size > maxSize) { maxSize = size; } } LOG.info("SPT: vertices: " + stateSets.size() + " states: total: " + statesCount + " per vertex max: " + maxSize + " avg: " + (statesCount * 1.0 / stateSets.size())); List<Integer> nStates = new ArrayList<Integer>(histogram.elementSet()); Collections.sort(nStates); for (Integer nState : nStates) { LOG.info(nState + " states: " + histogram.count(nState) + " vertices."); } }