本文整理了Java中cc.mallet.types.Instance.getData()
方法的一些代码示例,展示了Instance.getData()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instance.getData()
方法的具体详情如下:
包路径:cc.mallet.types.Instance
类名称:Instance
方法名:getData
暂无
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public TokenInstanceIterator (Iterator<Instance> source) {
if (source.hasNext()) {
currentInstance = source.next();
currentTokenSequence = (TokenSequence) currentInstance.getData();
}
currentIndex = 0;
}
public Instance next () {
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public Instance pipe (Instance carrier) {
if (carrier.getData() instanceof CharSequence) {
CharSequence data = (CharSequence) carrier.getData();
carrier.setData(data.toString().toLowerCase());
}
else {
throw new IllegalArgumentException("CharSequenceLowercase expects a CharSequence, found a " + carrier.getData().getClass());
}
return carrier;
}
代码示例来源:origin: cc.mallet/mallet
public Instance pipe (Instance carrier)
{
if (!(carrier.getData() instanceof CharSequence))
throw new IllegalArgumentException ();
String s = carrier.getData().toString();
String[] lines = s.split (System.getProperty ("line.separator"));
carrier.setData (new TokenSequence (lines));
return carrier;
}
代码示例来源:origin: cc.mallet/mallet
public Instance pipe (Instance carrier)
{
carrier.setSource (carrier.getData());
return carrier;
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public Instance pipe (Instance carrier)
{
String string = ((CharSequence)carrier.getData()).toString();
Matcher m = regex.matcher(string);
carrier.setData(m.replaceAll (replacement));
return carrier;
}
代码示例来源:origin: cc.mallet/mallet
public Instance next ()
{
Instance carrier = super.next();
carrier.setData(((File)carrier.getData()).toURI());
return carrier;
}
代码示例来源:origin: cc.mallet/mallet
public BitSet preProcess(InstanceList data) {
// count number of tokens
BitSet bitSet = new BitSet(data.size());
bitSet.set(0, data.size(), true);
for (Instance instance : data) {
FeatureVectorSequence fvs = (FeatureVectorSequence)instance.getData();
this.numTokens += fvs.size();
}
return bitSet;
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public Instance pipe (Instance instance) {
TokenSequence sequence = (TokenSequence) instance.getData();
Token token = sequence.get(0);
token.setFeatureValue(featureName, 1.0);
return instance;
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public Instance pipe (Instance carrier)
{
carrier.setData(new AugmentableFeatureVector ((FeatureSequence)carrier.getData(), binary));
return carrier;
}
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
/**
Calculates the confidence in the tagging of a {@link Instance}.
*/
public double estimateConfidenceFor (Instance instance,
Object[] startTags,
Object[] inTags) {
SumLatticeDefault lattice = new SumLatticeDefault (model, (Sequence)instance.getData());
SequencePairAlignment viterbi = new MaxLatticeDefault (model, (Sequence)instance.getData()).bestOutputAlignment();
return Math.exp (viterbi.getWeight() - lattice.getTotalWeight());
}
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public Instance pipe (Instance carrier)
{
TokenSequence ts = (TokenSequence) carrier.getData();
for (int i = 0; i < ts.size(); i++) {
Token t = ts.get(i);
String s = t.getText();
if (s.length() > prefixLength)
t.setFeatureValue ((prefix + s.substring (0, prefixLength)), 1.0);
}
return carrier;
}
代码示例来源:origin: cc.mallet/mallet
public Double call() throws Exception {
double value = 0;
for (int ii = start; ii < end; ii++) {
Instance inst = trainingSet.get(ii);
Sequence input = (Sequence) inst.getData();
// logZ
value -= new SumLatticePR(crf, ii, input, null, modelCopy, cachedDots[ii], true, null, null, false).getTotalWeight();
}
return value;
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public double predict(Instance instance) {
double prediction = parameters[interceptIndex];
FeatureVector predictors = (FeatureVector) instance.getData();
for (int location = 0; location < predictors.numLocations(); location++) {
int index = predictors.indexAtLocation(location);
prediction += parameters[index] * predictors.valueAtLocation(location);
}
return prediction;
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public Instance pipe (Instance carrier)
{
FeatureVector fv = (FeatureVector) carrier.getData();
carrier.setData(new FeatureVector (fv, fv.getAlphabet(), null, null));
return carrier;
}
代码示例来源:origin: cc.mallet/mallet
public Instance pipe (Instance carrier)
{
TokenSequence ts = (TokenSequence) carrier.getData();
for (int i = 0; i < ts.size(); i++) {
Token t = ts.get(i);
if (matchingRegex == null || matchingRegex.matcher(t.getText()).matches()) {
t.setFeatureValue (prefix == null ? t.getText() : (prefix+t.getText()), 1.0);
}
}
return carrier;
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public Instance next ()
{
Instance inst = subIt.next ();
inst = pipe.pipe (inst);
return new Instance (inst.getData (), inst.getTarget (), inst.getName (), inst.getSource ());
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public Classification classify (Instance instance)
{
FeatureVector fv = (FeatureVector) instance.getData ();
assert (instancePipe == null || fv.getAlphabet () == this.instancePipe.getDataAlphabet ());
Node leaf = getLeaf (root, fv);
return new Classification (instance, this, leaf.labeling);
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public Sequence pipeInput (Object input)
{
InstanceList all = new InstanceList (getFeaturePipe ());
all.add (input, null, null, null);
return (Sequence) all.get (0).getData();
}
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public Classification classify (Instance instance)
{
FeatureVector fv = (FeatureVector) instance.getData ();
assert (instancePipe == null || fv.getAlphabet () == this.instancePipe.getDataAlphabet ());
Node leaf = getLeaf(m_root, fv);
return new Classification (instance, this, leaf.getGainRatio().getBaseLabelDistribution());
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public static void main(String[] args) {
String htmldir = args[0];
Pipe pipe = new SerialPipes(new Pipe[] { new Input2CharSequence(),
new CharSequenceRemoveHTML() });
InstanceList list = new InstanceList(pipe);
list.addThruPipe(new FileIterator(htmldir, FileIterator.STARTING_DIRECTORIES));
for (int index = 0; index < list.size(); index++) {
Instance inst = list.get(index);
System.err.println(inst.getData());
}
}
内容来源于网络,如有侵权,请联系作者删除!