List of usage examples for java.util Arrays stream
public static DoubleStream stream(double[] array)
From source file:io.dfox.junit.http.api.Path.java
/** * Parse a String into a RunPath. The path is expected to be in the format * <grouping>[/<name>]. * // ww w.j av a 2s. co m * @param path The string path * @return The test path or an empty Optional if the path is not valid or could not be parsed */ public static Optional<Path> parse(final String path) { final ImmutableList<String> parts = Arrays.stream(path.split("/")).map(s -> s.trim()) .filter(s -> !s.isEmpty()).collect(Collectors.toImmutableList()); switch (parts.size()) { case 1: return Optional.of(new Path(parts.get(0), Optional.empty())); case 2: return Optional.of(new Path(parts.get(0), Optional.of(parts.get(1)))); default: return Optional.empty(); } }
From source file:com.tekstosense.opennlp.config.ModelLoaderConfig.java
public static String[] getModels(String[] modelNames) { File dir = new File(Config.getConfiguration().getString(MODELPATH)); LOG.info("Loading Models from... " + dir.getAbsolutePath()); List<String> wildCardPath = Arrays.stream(modelNames).map(model -> { return "en-ner-" + model + "*.bin"; }).collect(Collectors.toList()); FileFilter fileFilter = new WildcardFileFilter(wildCardPath, IOCase.INSENSITIVE); List<String> filePath = Arrays.asList(dir.listFiles(fileFilter)).stream() .map(file -> file.getAbsolutePath()).collect(Collectors.toList()); return filePath.toArray(new String[filePath.size()]); }
From source file:org.shredzone.cilla.admin.ListBean.java
/** * Returns a list of available text format types. */// w w w .j a va 2 s . c om public List<SelectItem> createTextFormatList() { ResourceBundle msg = getResourceBundle(); return Arrays.stream(TextFormat.values()).map(TextFormat::name).map(value -> { String label = msg.getString("select.textformat." + value.toLowerCase()); String description = msg.getString("select.textformat.tt." + value.toLowerCase()); return new SelectItem(value, label, description); }).collect(toList()); }
From source file:net.lldp.checksims.parse.token.tokenizer.CharTokenizer.java
/** * Split a string into character tokens. * * @param string String to split/*www . jav a 2 s . co m*/ * @return Input string, with a single token representing each character */ @Override public TokenList splitString(String string) { checkNotNull(string); TokenList toReturn = new TokenList(this.getType()); char[] chars = string.toCharArray(); Arrays.stream(ArrayUtils.toObject(chars)) .map((character) -> new ConcreteToken(character, TokenType.CHARACTER)) .forEachOrdered(toReturn::add); return toReturn; }
From source file:com.thoughtworks.go.config.CaseInsensitiveString.java
public static List<CaseInsensitiveString> list(String... strings) { return toList(Arrays.stream(strings)); }
From source file:com.nike.cerberus.command.validator.UploadCertFilesPathValidator.java
@Override public void validate(final String name, final Path value) throws ParameterException { if (value == null) { throw new ParameterException("Value must be specified."); }/* w ww . ja v a 2 s . co m*/ final File certDirectory = value.toFile(); final Set<String> filenames = Sets.newHashSet(); if (!certDirectory.canRead()) { throw new ParameterException("Specified path is not readable."); } if (!certDirectory.isDirectory()) { throw new ParameterException("Specified path is not a directory."); } final FilenameFilter filter = new RegexFileFilter("^.*\\.pem$"); final File[] files = certDirectory.listFiles(filter); Arrays.stream(files).forEach(file -> filenames.add(file.getName())); if (!filenames.containsAll(EXPECTED_FILE_NAMES)) { final StringJoiner sj = new StringJoiner(", ", "[", "]"); EXPECTED_FILE_NAMES.stream().forEach(sj::add); throw new ParameterException("Not all expected files are present! Expected: " + sj.toString()); } }
From source file:com.serli.open.data.poitiers.jobs.importer.ImportAllDataJob.java
@Override protected void indexRootElement(FullDataJsonFile fullDataJsonFile) { DataJsonObject[] jsonDataFromFiles = fullDataJsonFile.data; System.out.println("index root 1"); Bulk.Builder bulk = new Bulk.Builder().defaultIndex(OPEN_DATA_POITIERS_INDEX).defaultType(getElasticType()); System.out.println("index root2"); Arrays.stream(jsonDataFromFiles).forEach(jsonFromFile -> bulk.addAction(getAction(jsonFromFile))); RuntimeJestClient jc = ElasticUtils.createClient(); jc.execute(bulk.build());//from w w w. ja v a 2 s . co m }
From source file:com.simiacryptus.util.test.EnglishWords.java
private static void read() { try {/*from w w w .j a v a 2 s .com*/ InputStream in = Util.cache(url, file); String txt = new String(IOUtils.toByteArray(in), "UTF-8").replaceAll("\r", ""); List<String> list = Arrays.stream(txt.split("\n")).map(x -> x.replaceAll("[^\\w]", "")) .collect(Collectors.toList()); Collections.shuffle(list); for (String paragraph : list) { queue.add(new EnglishWords(paragraph)); } } catch (final IOException e) { // Ignore... end of stream } catch (final RuntimeException e) { if (!(e.getCause() instanceof InterruptedException)) throw e; } catch (final Exception e) { throw new RuntimeException(e); } }
From source file:edu.umd.umiacs.clip.tools.classifier.ConfusionMatrix.java
public static ConfusionMatrix loadLibSVM(String goldPath, String predPath, double... cutoffs) { int[] gold = readAllLines(goldPath).stream().mapToInt(line -> new Integer(line.split("\\s+")[0])).toArray(); IntSummaryStatistics stats = Arrays.stream(gold).summaryStatistics(); double cutoff = stats.getMin() == stats.getMax() ? cutoffs[0] : ((stats.getMax() + stats.getMin()) / 2); List<Boolean> goldList = Arrays.stream(gold).boxed().map(i -> i > cutoff).collect(toList()); List<Boolean> predList = readAllLines(predPath).stream().map(pred -> new Double(pred) > cutoff) .collect(toList());//ww w . j av a2 s.co m return new ConfusionMatrix(goldList, predList); }
From source file:com.google.cloud.tools.intellij.appengine.facet.standard.AppEngineStandardMavenLibrary.java
public static Optional<AppEngineStandardMavenLibrary> getLibraryByDisplayName(final String name) { return Arrays.stream(AppEngineStandardMavenLibrary.values()) .filter(library -> name.equals(library.getDisplayName())).findAny(); }