use of tech.tablesaw.api.StringColumn in project symja_android_library by axkr.
the class StringMapFunctions method tokenizeAndSort.
default StringColumn tokenizeAndSort(String separator) {
StringColumn newColumn = StringColumn.create(name() + "[sorted]", 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));
Collections.sort(tokens);
value = String.join(separator, tokens);
newColumn.set(r, value);
}
return newColumn;
}
use of tech.tablesaw.api.StringColumn in project symja_android_library by axkr.
the class StringMapFunctions method tokens.
/**
* Returns a column of arbitrary size containing each token in this column, where a token is
* defined using the given separator.
*
* <p>NOTE: Unlike other map functions, this method produces a column whose size may be different
* from the source, so they cannot safely be combined in a table.
*
* @param separator the delimiter used in the tokenizing operation
* @return a new column
*/
default StringColumn tokens(String separator) {
StringColumn newColumn = StringColumn.create(name() + "[token count]");
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));
for (String token : tokens) {
newColumn.append(token);
}
}
return newColumn;
}
use of tech.tablesaw.api.StringColumn in project symja_android_library by axkr.
the class StringMapFunctions method commonSuffix.
default StringColumn commonSuffix(Column<String> column2) {
StringColumn newColumn = StringColumn.create(name() + column2.name() + "[suffix]");
for (int r = 0; r < size(); r++) {
String value1 = getString(r);
String value2 = column2.getString(r);
newColumn.append(Strings.commonSuffix(value1, value2));
}
return newColumn;
}
use of tech.tablesaw.api.StringColumn in project symja_android_library by axkr.
the class StringMapFunctions method concatenate.
/**
* Return a copy of this column with the corresponding value of each column argument appended to
* each element. getString is used to ensure the value returned by the args are strings
*
* @param stringColumns the string columns to append
* @return the new column
*/
default StringColumn concatenate(Column<?>... stringColumns) {
StringColumn newColumn = StringColumn.create(name() + "[append]", this.size());
for (int r = 0; r < size(); r++) {
StringBuilder s = new StringBuilder(getString(r));
for (Column<?> stringColumn : stringColumns) s.append(stringColumn.getString(r));
newColumn.set(r, s.toString());
}
return newColumn;
}
use of tech.tablesaw.api.StringColumn in project symja_android_library by axkr.
the class Stats method asTableComplete.
public Table asTableComplete() {
Table t = asTable();
StringColumn measure = t.stringColumn("Measure");
DoubleColumn value = t.doubleColumn("Value");
measure.append("Sum of Squares");
value.append(sumOfSquares());
measure.append("Sum of Logs");
value.append(sumOfLogs());
measure.append("Population Variance");
value.append(populationVariance());
measure.append("Geometric Mean");
value.append(geometricMean());
measure.append("Quadratic Mean");
value.append(quadraticMean());
measure.append("Second Moment");
value.append(secondMoment());
return t;
}
Aggregations