本文整理了Java中se.lth.cs.srl.corpus.Yield
类的一些代码示例,展示了Yield
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Yield
类的具体详情如下:
包路径:se.lth.cs.srl.corpus.Yield
类名称:Yield
暂无
代码示例来源:origin: microth/PathLSTM
if (isContinuous())
return Arrays.asList(this);
Collection<Yield> ret = new TreeSet<>();
String curArgLabel = argLabel;
Yield subYield = new Yield(pred, sen, curArgLabel);
for (int i = this.first().idx; i <= this.last().idx; ++i) {
Word curWord = sen.get(i);
if (this.contains(curWord)) { // If this yield contain the word, add
subYield.add(curWord);
} else if (!subYield.isEmpty()) { // If this yield doesn't contain
subYield = new Yield(pred, sen, curArgLabel);
if (!subYield.isEmpty()) // Add the last subyield
ret.add(subYield);
return ret;
代码示例来源:origin: com.googlecode.mate-tools/srl
/**
* Returns the yield of this word, ie the complete phrase that defines the argument,
* with respect to the predicate. It follows algorithm 5.3 in Richard Johansson (2008), page 88
* @param pred The predicate of the proposition, required to deduce the yield
* @return the Yield
*/
public Yield getYield(Predicate pred,String argLabel,Set<Word> argSet){
Yield ret=new Yield(pred,mySentence,argLabel);
ret.add(this);
if(pred==this) //If the predicate is the argument, we don't consider the yield
return ret;
for(Word child:children){
if(!argSet.contains(child)){ //We don't branch down this child if
Collection<Word> subtree=getDominated(Arrays.asList(child));
if(!subtree.contains(pred))
ret.addAll(subtree);
}
}
//ret.addAll(getDominated(children));
return ret;
}
代码示例来源:origin: microth/PathLSTM
/**
* Checks whether this yield is continuous, ie they contain all the words in
* the sentence between this.first() and this.last(). Yields with 1 word are
* always continuous
*
* @return true if this yield is continuous, false otherwise
*/
public boolean isContinuous() {
if (this.size() < 2)
return true;
int senIndex = this.first().idx;
for (Word w : this) {
if (w.idx != senIndex++)
return false;
}
return true;
}
代码示例来源:origin: com.googlecode.mate-tools/srl
Map<Word,String> argmap=pred.getArgMap();
for(Word arg:argmap.keySet()){
yields.addAll(arg.getYield(pred,argmap.get(arg),argmap.keySet()).explode());
if(!y.isContinuous()){ //Warn the user if we have discontinuous yields
errors.append("((Discontinous yield of argument '"+y+"' of predicate '"+pred.getSense()+"'. Yield contains tokens [");
for(Word w:y)
errors.append("])).\n");
int blankColSpan=sen.indexOf(y.first())-indexCount;
if(blankColSpan>0){
ret.append("<td colspan=\"").append(blankColSpan).append("\"> </td>");
} else if(blankColSpan<0){
errors.append("Argument '"+y.getArgLabel()+"' of '"+pred.getSense()+"' at index "+indexCount+" overlaps with previous argument(s), ignored.\n");
continue;
int argColWidth=sen.indexOf(y.last())-sen.indexOf(y.first())+1;
String argLabel=y.getArgLabel();
ret.append("<td colspan=\"")
.append(argColWidth)
代码示例来源:origin: CogComp/cogcomp-nlp
String argDesc = (frameData != null) ? FramesManager.getArgDcrp(argTag, frameData): "";
Yield y = a.getYield(p, argTag, singleton);
IntPair span = new IntPair(y.first().getIdx() - 1, y.last().getIdx());
String argLabel = (argDesc.length() > 1) ? argTag + "." + argDesc : argTag;
Constituent c = new Constituent(argLabel, viewName, ta,
代码示例来源:origin: com.googlecode.mate-tools/srl
/**
* Compares yields. Yields are sorted according to their left-most token.
* I.e. with three yields with first element tokens with ID's 1, 7, and 5 respectively,
* they will be sorted in the order 1, 5, 7, regardless of gaps and continuity
*/
@Override
public int compareTo(Yield y) {
return this.first().getMySentence().wordComparator.compare(this.first(),y.first());
}
/**
代码示例来源:origin: microth/PathLSTM
/**
* Compares yields. Yields are sorted according to their left-most token.
* I.e. with three yields with first element tokens with ID's 1, 7, and 5
* respectively, they will be sorted in the order 1, 5, 7, regardless of
* gaps and continuity
*/
@Override
public int compareTo(Yield y) {
return this.first().getMySentence().wordComparator.compare(
this.first(), y.first());
}
代码示例来源:origin: com.googlecode.mate-tools/srl
/**
* Breaks this yield down to continuous yields if this yield is discontinuous, otherwise it returns itself in a list.
* Yields are labeled lab, C-lab, C-C-lab, etc in a sequential manner from left to right.
* It follows algorithm 5.3 in Richard Johansson (2008), page 88
* @return a collection of continuous yields
*/
public Collection<Yield> explode() {
if(isContinuous())
return Arrays.asList(this);
Collection<Yield> ret=new TreeSet<Yield>();
String curArgLabel=argLabel;
Yield subYield=new Yield(pred,sen,curArgLabel);
for(int i=sen.indexOf(this.first());i<=sen.indexOf(this.last());++i){
Word curWord=sen.get(i);
if(this.contains(curWord)){ //If this yield contain the word, add it, it's continuous.
subYield.add(curWord);
} else if(!subYield.isEmpty()) { //If this yield doesn't contain the word, and we have an unempty subyield, then the subyield is completed
ret.add(subYield);
curArgLabel="C-"+curArgLabel;
subYield=new Yield(pred,sen,curArgLabel);
}
}
if(!subYield.isEmpty()) //Add the last subyield
ret.add(subYield);
return ret;
}
}
代码示例来源:origin: microth/PathLSTM
public Yield getYield(Word pred, String argLabel, Set<Word> argSet) {
Yield ret = new Yield(pred, mySentence, argLabel);
ret.add(this);
if (pred.idx == this.idx) // If the predicate is the argument, we don't
// consider the yield
return ret;
Set<Integer> args = new TreeSet<>();
for (Word w : argSet)
args.add(w.getIdx());
for (Word child : children) {
if (!args.contains(child.idx)) { // We don't branch down this child
// if
Collection<Word> subtree = getDominated(Arrays.asList(child));
boolean containspred = false;
for (Word w : subtree)
if (w.idx == pred.idx)
containspred = true;
if (!containspred)
// if(!subtree.contains(mySentence.get(pred.idx)));
ret.addAll(subtree);
}
}
// ret.addAll(getDominated(children));
return ret;
}
代码示例来源:origin: com.googlecode.mate-tools/srl
/**
* Checks whether this yield is continuous, ie they contain all the words in the
* sentence between this.first() and this.last(). Yields with 1 word are always continuous
* @return true if this yield is continuous, false otherwise
*/
public boolean isContinuous(){
if(this.size()<2)
return true;
int senIndex=sen.indexOf(this.first());
for(Word w:this){
if(sen.get(senIndex++)!=w)
return false;
}
return true;
}
内容来源于网络,如有侵权,请联系作者删除!