
cc.mallet.pipe.TargetStringToFeatures Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jcore-mallet-2.0.9 Show documentation
Show all versions of jcore-mallet-2.0.9 Show documentation
MALLET is a Java-based package for statistical natural language processing, document classification, clustering, topic modeling, information extraction, and other machine learning applications to text.
The newest version!
package cc.mallet.pipe;
import cc.mallet.types.*;
import java.io.Serializable;
import java.util.Arrays;
public class TargetStringToFeatures extends Pipe implements Serializable {
public TargetStringToFeatures () {
super(null, new Alphabet());
}
public Instance pipe(Instance carrier) {
if (! (carrier.getTarget() instanceof String)) {
throw new IllegalArgumentException("Target must be of type String");
}
String featuresLine = (String) carrier.getTarget();
String[] features = featuresLine.split(",?\\s+");
double[] values = new double[ features.length ];
Arrays.fill(values, 1.0);
for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy