本文整理汇总了Java中is2.data.SentenceData09类的典型用法代码示例。如果您正苦于以下问题:Java SentenceData09类的具体用法?Java SentenceData09怎么用?Java SentenceData09使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SentenceData09类属于is2.data包,在下文中一共展示了SentenceData09类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSemEdge
import is2.data.SentenceData09; //导入依赖的package包/类
/**
* @param i
* @param n
* @param p
* @param l
*/
public static Edge getSemEdge(SentenceData09 i, int n, int p, String l) {
StringBuffer key = new StringBuffer();
key.append(l);
// Edge e = null;
Edge e = mappingList.get(key.toString());
key.append('*').append(i.gpos[n]);
// take the more specific
Edge e1 = mappingList.get(key.toString());
if (e1!=null) e=e1;
if (e==null) {
e = new Edge (true,"A");
DB.println("found no mapping for "+i.gpos[p]+" "+l+" -> "+i.gpos[n]+" forms "+i.forms[p]+" "+l+" -> "+i.forms[n] );
notConnectedCount++;
}
return e;
}
示例2: getPath
import is2.data.SentenceData09; //导入依赖的package包/类
private ArrayList<Integer> getPath(int s1, int s2, SentenceData09 sure) {
ArrayList<Integer> p = new ArrayList<Integer>();
int h = s2;;
p.add(h);
while(true) {
h = sure.heads[h];
p.add(h);
if (h==s1) break;
if (p.size()>3) {
System.out.println("path not found "+p);
p.clear();
break;
}
}
return p;
}
示例3: main
import is2.data.SentenceData09; //导入依赖的package包/类
public static void main(String[] args) throws Exception{
File desegmentedInput=new File("chi-desegmented.out");
Tokenizer tokenizer=new StanfordChineseSegmenterWrapper(new File("/home/anders/Download/stanford-chinese-segmenter-2008-05-21/data"));
Lemmatizer lemmatizer=new SimpleChineseLemmatizer();
Tagger tagger=BohnetHelper.getTagger(new File("models/chi/tag-chn.model"));
Preprocessor pp=new Preprocessor(tokenizer,lemmatizer,tagger,null,null);
BufferedReader reader=new BufferedReader(new InputStreamReader(new FileInputStream(desegmentedInput),"UTF-8"));
String line;
while((line=reader.readLine())!=null){
String[] tokens=pp.tokenize(line);
SentenceData09 s=pp.preprocess(tokens);
System.out.println(s);
}
}
示例4: Sentence
import is2.data.SentenceData09; //导入依赖的package包/类
public Sentence(SentenceData09 data, boolean skipTree) {
this();
int offset = 0;
if (data.pheads[0] == -1)
offset++;
for (int i = 0 + offset; i < data.forms.length; ++i) {
Word nextWord = new Word(data.forms[i], data.plemmas[i],
data.ppos[i], data.pfeats[i], this, i + 1 - offset);
super.add(nextWord);
}
if (skipTree)
return;
for (int i = 0; i < data.forms.length - offset; ++i) {
Word curWord = super.get(i + 1);
curWord.setHead(super.get(data.pheads[i + offset]));
curWord.setDeprel(data.plabels[i + offset]);
}
this.buildDependencyTree();
}
示例5: nextInstance
import is2.data.SentenceData09; //导入依赖的package包/类
/**
* Creates an instance for outputParses
*
* @param is
* @return
* @throws IOException
*/
protected final SentenceData09 nextInstance(Instances is, CONLLReader09 depReader) throws Exception {
SentenceData09 instance = depReader.getNext(is);
if (instance == null || instance.forms == null) return null;
return instance;
}
示例6: Word
import is2.data.SentenceData09; //导入依赖的package包/类
public Word(SentenceData09 i, int k, String ft ) {
form = i.forms[k];
lemma = i.lemmas[k];
gpos = i.gpos[k];
ppos = i.ppos[k];
lable =i.labels[k];
if (ft!=null)feats ="id="+k+(ft.length()>0?"|"+ft:"");
}
示例7: getChilds
import is2.data.SentenceData09; //导入依赖的package包/类
/**
* @param r
* @param d
* @return
*/
public ArrayList<Integer> getChilds(int h, SentenceData09 d) {
ArrayList<Integer> cs = new ArrayList<Integer>();
for(int i=0;i<d.length();i++) {
if (d.heads[i]==h) cs.add(i);
}
return cs;
}
示例8: getLeafs
import is2.data.SentenceData09; //导入依赖的package包/类
/**
* Get all leafs
* @param ds
* @return
*/
public int[] getLeafs(SentenceData09 ds) {
// count the leafs
int leafCount=0;
for(int i=0;i<ds.length();i++) if (!hasChild(i,ds)) leafCount++;
int leafs[] = new int[leafCount];
leafCount=0;
for(int i=0;i<ds.length();i++) {
if (!hasChild(i,ds)) leafs[leafCount++]=i;
}
return leafs;
}
示例9: hasChild
import is2.data.SentenceData09; //导入依赖的package包/类
/**
* Has n at least one child?
* @param n
* @param ds
* @return
*/
private boolean hasChild(int n, SentenceData09 ds) {
for(int i=ds.length()-1;i>=0;i--) {
if (ds.heads[i]==n) return true;
}
return false;
}
示例10: tag
import is2.data.SentenceData09; //导入依赖的package包/类
public SentenceData09 tag(SentenceData09 instance, OptionsSuper options){
InstancesTagger is = new InstancesTagger();
is.init(1, pipe.mf);
new CONLLReader09().insert(is, instance);
is.fillChars(instance, 0, Pipe._CEND);
tag(is, instance,options.stack);
return instance;
}
示例11: getChildren
import is2.data.SentenceData09; //导入依赖的package包/类
public static ArrayList<ID> getChildren(SentenceData09 instance, int head) {
ArrayList<ID> children = new ArrayList<ID>();
for(int i=0;i<instance.length();i++) {
if (instance.heads[i]==head) {
String id = instance.id[i];
if (id.contains("_")) {
id = id.split("_")[1];
}
children.add(new ID(id,i));
}
}
return children;
}
示例12: apply
import is2.data.SentenceData09; //导入依赖的package包/类
@Override
public SentenceData09 apply(SentenceData09 instance) {
for(int i=0;i<instance.forms.length;++i)
instance.plemmas[i]=instance.forms[i];
return instance;
}
示例13: Sentence
import is2.data.SentenceData09; //导入依赖的package包/类
public Sentence(SentenceData09 data){
this();
for(int i=0;i<data.forms.length;++i){
Word nextWord=new Word(data.forms[i],data.plemmas[i],data.ppos[i],data.pfeats[i],this,i+1);
super.add(nextWord);
}
for(int i=0;i<data.forms.length;++i){
Word curWord=super.get(i+1);
curWord.setHead(super.get(data.pheads[i]));
curWord.setDeprel(data.plabels[i]);
}
this.buildDependencyTree();
}
示例14: parseX
import is2.data.SentenceData09; //导入依赖的package包/类
public Sentence parseX(List<StringInText> words) throws Exception {
String[] array = new String[words.size()];
for (int i = 0; i < array.length; i++)
array[i] = words.get(i).word();
SentenceData09 tmp = pp.preprocess(array);
Sentence s = new Sentence(tmp, false);
for (int i = 0; i < array.length; i++) {
s.get(i).setBegin(words.get(i).begin());
s.get(i).setEnd(words.get(i).end());
}
srl.parse(s);
return s;
}
示例15: apply
import is2.data.SentenceData09; //导入依赖的package包/类
@Override
public SentenceData09 apply(SentenceData09 instance) {
for (int i = 0; i < instance.forms.length; ++i)
instance.plemmas[i] = instance.forms[i];
return instance;
}