Package com.google.common.base

Examples of com.google.common.base.Splitter$SplittingIterator


    private String key;

    public LogisticRegressionEval(String modelParams) throws IOException {
        System.out.printf("Model params = %s\n", modelParams);

        Splitter onComma = Splitter.on(",").trimResults().omitEmptyStrings();
        Splitter onEquals = Splitter.on("=").trimResults();
        Joiner withSpaces = Joiner.on(" ");

        Map<String, String> options = Maps.newHashMap();

        for (String option : onComma.split(modelParams)) {
            List<String> values = Lists.newArrayList(onEquals.split(option));
            options.put(values.get(0), values.get(1));
        }

        if (options.containsKey("sequence")) {
            location = options.get("sequence");
View Full Code Here


                        fullPath));
        return matchedPattern.isPresent();
    }

    public PathDocumentFilter setPattern(String pattern) {
        Splitter splitter =
                Splitter.on(DOCUMENT_FILTER_LIST_DELIMITER).trimResults()
                        .omitEmptyStrings();
        patterns = Sets.newHashSet(splitter.split(pattern));
        patternsInLowerCase =
                Sets.newHashSet(splitter.split(pattern.toLowerCase()));
        return this;
    }
View Full Code Here

    assertEquals(0, m.minus(svd.getU().times(svd.getS()).times(svd.getV().transpose())).aggregate(Functions.PLUS, Functions.ABS), 1e-10);
    System.out.printf("No hang\n");
  }

  Matrix readTsv(String name) throws IOException {
    Splitter onTab = Splitter.on("\t");
    List<String> lines = Resources.readLines((Resources.getResource(name)), Charsets.UTF_8);
    int rows = lines.size();
    int columns = Iterables.size(onTab.split(lines.get(0)));
    Matrix r = new DenseMatrix(rows, columns);
    int row = 0;
    for (String line : lines) {
      Iterable<String> values = onTab.split(line);
      int column = 0;
      for (String value : values) {
        r.set(row, column, Double.parseDouble(value));
        column++;
      }
View Full Code Here

    }

    @Inject(value = "struts.freeroute.controllerSuffixes", required = true)
    private void setControllerSuffixes(String controllerSuffixes) {

        Splitter splitter = Splitter.on(",").trimResults().omitEmptyStrings();
        this.controllerSuffixes = Sets.newHashSet(splitter.split(controllerSuffixes));
    }
View Full Code Here

        if (detectors != null) {
            Project p = main != null ? main : project;
            List<File> files = new ArrayList<File>();
            String paths = p.getProguardPath();
            if (paths != null) {
                Splitter splitter = Splitter.on(CharMatcher.anyOf(":;")); //$NON-NLS-1$
                for (String path : splitter.split(paths)) {
                    if (path.contains("${")) { //$NON-NLS-1$
                        // Don't analyze the global/user proguard files
                        continue;
                    }
                    File file = new File(path);
View Full Code Here

        public String asString() {
            return sb.toString();
        }

        public Iterator<String> getIterator() {
            Splitter page = Splitter.fixedLength(PAGE_SIZE);
            return page.split(sb.toString()).iterator();
        }
View Full Code Here

        return this;
    }

    public static ImmutableSet<HostAddress> parseNodes(String nodes)
    {
        Splitter splitter = Splitter.on(',').omitEmptyStrings().trimResults();
        return ImmutableSet.copyOf(transform(splitter.split(nodes), toHostAddress()));
    }
View Full Code Here

    private static RecordSet readRecords(String name, List<ColumnMetadata> columns)
            throws IOException
    {
        // tpch does not contain nulls, but does have a trailing pipe character,
        // so omitting empty strings will prevent an extra column at the end being added
        Splitter splitter = Splitter.on('|').omitEmptyStrings();
        return new DelimitedRecordSet(readResource(name), splitter, columns);
    }
View Full Code Here

    List<String> prova = linesOf(name);
    assertLines(lines, prova);
  }

  public static void assertLines(String hasLines, String exp) {
    Splitter splitter = Splitter.on('\n');
    List<String> lines = splitter.splitToList(hasLines);
    List<String> asser = splitter.splitToList(exp);
    assertLines(lines, asser);
  }
View Full Code Here

            out.newLine();
        }
        out.close();

        // now generate a session for each user
        Splitter onTabs = Splitter.on("\t");
        Splitter onComma = Splitter.on(",");

        Random gen = new Random();
        SchemaSampler intermediate = new SchemaSampler(Resources.asCharSource(Resources.getResource("hit_step.txt"), Charsets.UTF_8).read());

        final int COUNTRY = users.getFieldNames().indexOf("country");
        final int CAMPAIGN = intermediate.getFieldNames().indexOf("campaign_list");
        final int SEARCH_TERMS = intermediate.getFieldNames().indexOf("search_keywords");
        Preconditions.checkState(COUNTRY >= 0, "Need country field in user schema");
        Preconditions.checkState(CAMPAIGN >= 0, "Need campaign_list field in step schema");
        Preconditions.checkState(SEARCH_TERMS >= 0, "Need search_keywords field in step schema");

        out = Files.newBufferedWriter(new File(opts.out).toPath(), Charsets.UTF_8);

        for (String line : Files.readAllLines(userFile.toPath(), Charsets.UTF_8)) {
            long t = (long) (TimeUnit.MILLISECONDS.convert(30, TimeUnit.DAYS) * gen.nextDouble());
            List<String> user = Lists.newArrayList(onTabs.split(line));

            // pick session length
            int n = (int) Math.floor(-30 * Math.log(gen.nextDouble()));

            for (int i = 0; i < n; i++) {
                // time on page
                int dt = (int) Math.floor(-20000 * Math.log(gen.nextDouble()));
                t += dt;

                // hit specific values
                JsonNode step = intermediate.sample();

                // check for purchase
                double p = 0.01;
                List<String> campaigns = Lists.newArrayList(onComma.split(step.get("campaign_list").asText()));
                List<String> keywords = Lists.newArrayList(onComma.split(step.get("search_keywords").asText()));
                if ((user.get(COUNTRY).equals("us") && campaigns.contains("5")) ||
                        (user.get(COUNTRY).equals("jp") && campaigns.contains("7")) ||
                        keywords.contains("homer") || keywords.contains("simpson")) {
                    p = 0.5;
                }
View Full Code Here

TOP

Related Classes of com.google.common.base.Splitter$SplittingIterator

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.