List of usage examples for com.google.common.collect Lists newArrayList
@GwtCompatible(serializable = true) public static <E> ArrayList<E> newArrayList()
From source file:org.apache.ctakes.relationextractor.eval.RelationExtractorEvaluation.java
public static void main(String[] args) throws Exception { // parse the options, validate them, and generate XMI if necessary final Options options = CliFactory.parseArguments(Options.class, args); SHARPXMI.validate(options);/* w w w.j a v a 2s . c o m*/ SHARPXMI.generateXMI(options); // determine the grid of parameters to search through // for the full set of LibLinear parameters, see: // https://github.com/bwaldvogel/liblinear-java/blob/master/src/main/java/de/bwaldvogel/liblinear/Train.java List<ParameterSettings> gridOfSettings = Lists.newArrayList(); for (float probabilityOfKeepingANegativeExample : new float[] { 1.0f }) {//0.5f, for (int solver : new int[] { 0 /* logistic regression */, 1 /* SVM */ }) { for (double svmCost : new double[] { 0.01, 0.05, 0.1, 0.5, 1, 5, 10, 50, 100 }) { gridOfSettings.add(new ParameterSettings(LibLinearStringOutcomeDataWriter.class, new Object[] { RelationExtractorAnnotator.PARAM_PROBABILITY_OF_KEEPING_A_NEGATIVE_EXAMPLE, probabilityOfKeepingANegativeExample }, new String[] { "-s", String.valueOf(solver), "-c", String.valueOf(svmCost) })); } } } // run an evaluation for each selected relation for (final String relationCategory : options.getRelations()) { // get the best parameters for the relation final Class<? extends BinaryTextRelation> relationClass = RELATION_CLASSES.get(relationCategory); ParameterSettings bestSettings = BEST_PARAMETERS.get(relationClass); // run the evaluation SHARPXMI.evaluate(options, bestSettings, gridOfSettings, new Function<ParameterSettings, RelationExtractorEvaluation>() { @Override public RelationExtractorEvaluation apply(@Nullable ParameterSettings params) { return new RelationExtractorEvaluation(new File("target/models/" + relationCategory), relationClass, ANNOTATOR_CLASSES.get(relationClass), params, options.getTestOnCTakes(), options.getAllowSmallerSystemArguments(), options.getIgnoreImpossibleGoldRelations(), options.getPrintErrors(), options.getClassWeights(), options.getExpandEvents()); } }); } }
From source file:com.enonic.cms.upgrade.task.datasource.JDOMDocumentHelper.java
public static List<Element> findElements(final Element parent, final String name) { final List<Element> list = Lists.newArrayList(); if (parent != null) { for (final Object o : parent.getContent(new ElementNameFilter(name))) { list.add((Element) o); }/*from www . j av a 2 s. co m*/ } return list; }
From source file:suneido.runtime.builtin.GetMacAddresses.java
private static ArrayList<String> getMacAddresses() { ArrayList<String> list = Lists.newArrayList(); try {//www. j a v a 2 s .com for (Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements();) { NetworkInterface ni = e.nextElement(); if (ni.isLoopback() || ni.isVirtual() || ni.isPointToPoint()) continue; byte[] mac = ni.getHardwareAddress(); if (mac != null && mac.length > 0) list.add(Util.bytesToString(mac)); } } catch (SocketException e) { throw new SuException("GetMacAddress failed - SocketException", e); } return list; }
From source file:org.eclipse.recommenders.tests.XtendUtils.java
public static final <K> List<K> newListWithFrequency(final Pair<K, Integer>... initial) { final ArrayList<K> result = Lists.newArrayList(); for (final Pair<K, Integer> p : initial) { for (int i = p.getValue(); i-- > 0;) { result.add(p.getKey());/*from w w w. j a va2 s . c o m*/ } } return result; }
From source file:com.jdonee.insight.data.TaskData.java
public static List<Task> randomTasks(int limit) { List<Task> tasks = Lists.newArrayList(); for (int i = 0; i < limit; i++) { tasks.add(randomTask());//w w w . j a v a 2 s .c om } return tasks; }
From source file:org.jnario.xbase.richstring.util.TextLines.java
public static List<TextLine> splitString(String text) { List<TextLine> result = Lists.newArrayList(); appendLines(text, result);//w w w . java2 s . co m return Collections.unmodifiableList(result); }
From source file:com.eryansky.modules.disk.utils.OrganExtendUtils.java
/** * ?//from w w w . jav a 2s. c om * @param organId ID * @return */ public static List<String> getLeaderUser(String organId) { List<String> list = Lists.newArrayList(); Organ organ = organManager.loadById(organId); list.add(organ.getManagerUserId()); list.add(organ.getSuperManagerUserId()); return list; }
From source file:org.carrot2.util.attribute.constraint.ConstraintFactory.java
/** * Create a list of constraints based on the provided <code>annotations</code>. *///from w ww . j a v a 2 s . c o m public static List<Constraint> createConstraints(Annotation... annotations) { final ArrayList<Constraint> constraints = Lists.newArrayList(); for (Annotation annotation : annotations) { if (isConstraintAnnotation(annotation.annotationType())) { constraints.add(createImplementation(annotation)); } } return constraints; }
From source file:org.apache.hadoop.hive.common.GcTimeMonitor.java
/** * Simple 'main' to facilitate manual testing of the pause monitor. * * This main function just leaks memory. Running this class will quickly * result in a "GC hell" and subsequent alerts from the GcTimeMonitor. *//*from ww w.j a va 2 s .co m*/ public static void main(String[] args) throws Exception { new GcTimeMonitor(20 * 1000, 500, 20, new GcTimeMonitor.GcTimeAlertHandler() { @Override public void alert(GcData gcData) { System.err .println("GcTimeMonitor alert. Current GC time percentage = " + gcData.getGcTimePercentage() + ", total run time = " + (gcData.getGcMonitorRunTimeMs() / 1000) + " sec" + ", total GC time = " + (gcData.getAccumulatedGcTimeMs() / 1000) + " sec"); } }).start(); List<String> list = Lists.newArrayList(); for (int i = 0;; i++) { list.add("This is a long string to fill memory quickly " + i); if (i % 100000 == 0) { System.out.println("Added " + i + " strings"); Thread.sleep(100); } } }
From source file:com.getbase.android.forger.Fields.java
static List<Field> allFieldsIncludingPrivateAndSuper(Class<?> klass) { List<Field> fields = Lists.newArrayList(); while (!klass.equals(Object.class)) { Collections.addAll(fields, klass.getDeclaredFields()); klass = klass.getSuperclass();// w w w. ja va 2 s. c om } return fields; }