📄 edgehistfeatures.java
字号:
package iitb.Model;import iitb.CRF.*;import iitb.Utils.*;/** * * @author Sunita Sarawagi * * Suppose if history size is H and number of labels in the model * graph is m, this will generate m^(H+1) features */ public class EdgeHistFeatures extends FeatureTypes { String fname; String labelNames[]; int histsize; Counters ctr; boolean allDone; int histArr[]; public EdgeHistFeatures(FeatureGenImpl m,String name, String labels[], int histsize) { super(m); fname=name; labelNames=labels; ctr = new Counters(histsize+1, m.numStates()); this.histsize = histsize; histArr = new int[histsize]; } public boolean startScanFeaturesAt(DataSequence data, int prevPos, int pos) { ctr.clear(); allDone = false; if (pos < histsize) allDone = true; return allDone; } public boolean hasNext() { return (histsize > 1) && !allDone; } public void next(FeatureImpl f) { f.ystart = ctr.value(1,1); f.yend = ctr.value(0,0); ctr.arrayCopy(histsize-1,1,histArr); f.historyArray = histArr; f.val = 1; allDone = !ctr.advance(); String name=""; for (int i = 0; i < histArr.length; i++) { if (histArr[i] != -1) { if (labelNames == null) { name += ctr.value(histsize-1,1); } else { int index = i + 1; name += fname+"."+index+"."+labelNames[model.label(f.ystart)]; } } } setFeatureIdentifier(ctr.value(histsize-1,0), model.label(f.yend),name,f); }};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -