use of tech.tablesaw.api.StringColumn in project symja_android_library by axkr.
the class StringMapFunctions method replaceFirst.
default StringColumn replaceFirst(String regex, String replacement) {
StringColumn newColumn = StringColumn.create(name() + "[repl]");
for (int r = 0; r < size(); r++) {
String value = getString(r);
newColumn.append(value.replaceFirst(regex, replacement));
}
return newColumn;
}
use of tech.tablesaw.api.StringColumn in project symja_android_library by axkr.
the class StringMapFunctions method tokenizeAndRemoveDuplicates.
default StringColumn tokenizeAndRemoveDuplicates(String separator) {
StringColumn newColumn = StringColumn.create(name() + "[without duplicates]", this.size());
for (int r = 0; r < size(); r++) {
String value = getString(r);
Splitter splitter = Splitter.on(separator);
splitter = splitter.trimResults();
splitter = splitter.omitEmptyStrings();
List<String> tokens = new ArrayList<>(splitter.splitToList(value));
String result = tokens.stream().distinct().collect(Collectors.joining(separator));
newColumn.set(r, result);
}
return newColumn;
}
use of tech.tablesaw.api.StringColumn in project symja_android_library by axkr.
the class StringMapFunctions method join.
/**
* Return a copy of this column with the given string appended
*
* @param columns the column to append
* @return the new column
*/
default StringColumn join(String separator, Column<?>... columns) {
StringColumn newColumn = StringColumn.create(name() + "[column appended]", this.size());
for (int r = 0; r < size(); r++) {
StringBuilder result = new StringBuilder(getString(r));
for (Column<?> stringColumn : columns) {
result.append(separator).append(stringColumn.get(r));
}
newColumn.set(r, result.toString());
}
return newColumn;
}
use of tech.tablesaw.api.StringColumn in project symja_android_library by axkr.
the class StringMapFunctions method replaceAll.
default StringColumn replaceAll(String regex, String replacement) {
StringColumn newColumn = StringColumn.create(name() + "[repl]");
for (int r = 0; r < size(); r++) {
String value = getString(r);
newColumn.append(value.replaceAll(regex, replacement));
}
return newColumn;
}
Aggregations