Class StringListToCountsNDArrayTransform
- java.lang.Object
-
- org.datavec.api.transform.transform.BaseTransform
-
- org.datavec.api.transform.transform.string.StringListToCountsNDArrayTransform
-
- Direct Known Subclasses:
StringListToIndicesNDArrayTransform
public class StringListToCountsNDArrayTransform extends BaseTransform
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanbinaryprotected intcolumnIdxprotected StringcolumnNameprotected Stringdelimiterprotected booleanignoreUnknownprotected Map<String,Integer>mapprotected StringnewColumnNameprotected List<String>vocabulary-
Fields inherited from class org.datavec.api.transform.transform.BaseTransform
inputSchema
-
-
Constructor Summary
Constructors Constructor Description StringListToCountsNDArrayTransform(String columnName, String newColumnName, List<String> vocabulary, String delimiter, boolean binary, boolean ignoreUnknown)StringListToCountsNDArrayTransform(String columnName, List<String> vocabulary, String delimiter, boolean binary, boolean ignoreUnknown)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcolumnName()Returns a singular column name this op is meant to run onString[]columnNames()Returns column names this op is meant to run onprotected Collection<Integer>getIndices(String text)protected INDArraymakeBOWNDArray(Collection<Integer> indices)Objectmap(Object input)Transform an object in to another objectList<Writable>map(List<Writable> writables)Transform a writable in to another writableObjectmapSequence(Object sequence)Transform a sequenceStringoutputColumnName()The output column name after the operation has been appliedString[]outputColumnNames()The output column names This will often be the same as the inputstatic List<String>readVocabFromFile(String path)voidsetInputSchema(Schema inputSchema)Set the input schema.StringtoString()Schematransform(Schema inputSchema)-
Methods inherited from class org.datavec.api.transform.transform.BaseTransform
getInputSchema, mapSequence
-
-
-
-
Constructor Detail
-
StringListToCountsNDArrayTransform
public StringListToCountsNDArrayTransform(String columnName, List<String> vocabulary, String delimiter, boolean binary, boolean ignoreUnknown)
- Parameters:
columnName- The name of the column to convertvocabulary- The possible tokens that may be present.delimiter- The delimiter for the Strings to convertignoreUnknown- Whether to ignore unknown tokens
-
StringListToCountsNDArrayTransform
public StringListToCountsNDArrayTransform(String columnName, String newColumnName, List<String> vocabulary, String delimiter, boolean binary, boolean ignoreUnknown)
- Parameters:
columnName- The name of the column to convertvocabulary- The possible tokens that may be present.delimiter- The delimiter for the Strings to convertignoreUnknown- Whether to ignore unknown tokens
-
-
Method Detail
-
readVocabFromFile
public static List<String> readVocabFromFile(String path) throws IOException
- Throws:
IOException
-
setInputSchema
public void setInputSchema(Schema inputSchema)
Description copied from interface:ColumnOpSet the input schema.- Specified by:
setInputSchemain interfaceColumnOp- Overrides:
setInputSchemain classBaseTransform
-
toString
public String toString()
- Specified by:
toStringin classBaseTransform
-
getIndices
protected Collection<Integer> getIndices(String text)
-
makeBOWNDArray
protected INDArray makeBOWNDArray(Collection<Integer> indices)
-
map
public List<Writable> map(List<Writable> writables)
Description copied from interface:TransformTransform a writable in to another writable- Parameters:
writables- the record to transform- Returns:
- the transformed writable
-
map
public Object map(Object input)
Transform an object in to another object- Parameters:
input- the record to transform- Returns:
- the transformed writable
-
outputColumnName
public String outputColumnName()
The output column name after the operation has been applied- Returns:
- the output column name
-
outputColumnNames
public String[] outputColumnNames()
The output column names This will often be the same as the input- Returns:
- the output column names
-
columnNames
public String[] columnNames()
Returns column names this op is meant to run on- Returns:
-
columnName
public String columnName()
Returns a singular column name this op is meant to run on- Returns:
-
-