use of com.google.common.base.Splitter in project zemberek-nlp by ahmetaa.
the class AmbiguityStats method noParse.
public void noParse(String... filename) throws IOException {
Histogram<String> uniques = new Histogram<>(1000000);
int total = 0;
for (String file : filename) {
List<String> lines = readAll(file);
Splitter splitter = Splitter.on(" ").omitEmptyStrings().trimResults();
for (String line : lines) {
for (String s : splitter.split(line)) {
WordAnalysis results = parser.analyze(s);
total++;
if (total % 50000 == 0) {
System.out.println("Processed: " + total);
}
if (results.analysisCount() == 0) {
uniques.add(s);
}
}
}
System.out.println("Total: " + total);
}
Stats st = new Stats(0.0002);
st.allCounts = (int) uniques.totalCount();
st.allUniques = uniques.size();
for (String s : uniques.getSortedList()) {
int count = uniques.getCount(s);
if (count > 5) {
st.significantCounts += count;
st.significantUniques++;
System.out.println(s + " : " + count);
}
}
st.dump();
}
use of com.google.common.base.Splitter in project netvirt by opendaylight.
the class ElanBridgeManager method getMultiValueMap.
private static Map<String, String> getMultiValueMap(String multiKeyValueStr) {
if (Strings.isNullOrEmpty(multiKeyValueStr)) {
return Collections.emptyMap();
}
Map<String, String> valueMap = new HashMap<>();
Splitter splitter = Splitter.on(OTHER_CONFIG_PARAMETERS_DELIMITER);
for (String keyValue : splitter.split(multiKeyValueStr)) {
String[] split = keyValue.split(OTHER_CONFIG_KEY_VALUE_DELIMITER, 2);
if (split.length == 2) {
valueMap.put(split[0], split[1]);
}
}
return valueMap;
}
use of com.google.common.base.Splitter in project netvirt by opendaylight.
the class NatUtil method getMultiValueMap.
public static Map<String, String> getMultiValueMap(String multiKeyValueStr) {
if (Strings.isNullOrEmpty(multiKeyValueStr)) {
return Collections.emptyMap();
}
Map<String, String> valueMap = new HashMap<>();
Splitter splitter = Splitter.on(OTHER_CONFIG_PARAMETERS_DELIMITER);
for (String keyValue : splitter.split(multiKeyValueStr)) {
String[] split = keyValue.split(OTHER_CONFIG_KEY_VALUE_DELIMITER, 2);
if (split.length == 2) {
valueMap.put(split[0], split[1]);
}
}
return valueMap;
}
use of com.google.common.base.Splitter in project closure-compiler by google.
the class TextDiffFactsBuilder method build.
/**
* Returns one or more Fact objects representing the difference between the expected and actual
* text strings, which must be specified by calling their methods before calling this one.
*/
public ImmutableList<Fact> build() {
try {
// The diff algorithm expects to work on a list, so we need to split the text into
// lines.
final Splitter lineSplitter = Splitter.on('\n');
final List<String> expectedLines = lineSplitter.splitToList(checkNotNull(expectedText));
final List<String> actualLines = lineSplitter.splitToList(checkNotNull(actualText));
final Patch<String> patch = DiffUtils.diff(expectedLines, actualLines);
final List<String> unifiedDiff = UnifiedDiffUtils.generateUnifiedDiff("expected", "actual", expectedLines, patch, /* contextSize= */
10);
return ImmutableList.of(fact(title, unifiedDiff.stream().collect(joining("\n"))));
} catch (DiffException e) {
// It may indicate a bug in the diff library itself.
throw new IllegalStateException(e);
}
}
Aggregations