本文整理汇总了Java中com.clearnlp.dependency.DEPArc.getLabel方法的典型用法代码示例。如果您正苦于以下问题:Java DEPArc.getLabel方法的具体用法?Java DEPArc.getLabel怎么用?Java DEPArc.getLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.clearnlp.dependency.DEPArc
的用法示例。
在下文中一共展示了DEPArc.getLabel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toReferentArgument
import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
static public void toReferentArgument(DEPArc arc)
{
String label = arc.getLabel();
if (label.startsWith("A"))
arc.setLabel(PREFIX_REFERENT + label);
else if (label.startsWith(PREFIX_CONCATENATION))
arc.setLabel(PREFIX_REFERENT + label.substring(PREFIX_CONCATENATION.length()));
}
示例2: expandSRL
import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
public String[][] expandSRL(DEPTree tree)
{
ObjectIntOpenHashMap<DEPNode> map = new ObjectIntOpenHashMap<DEPNode>();
int i = 0, predId = 0, size = tree.size();
DEPNode pred, arg;
String label;
while ((pred = tree.getNextPredicate(predId)) != null)
{
map.put(pred, i++);
predId = pred.id;
}
if (map.isEmpty()) return null;
String[][] spans = new String[size][];
int len = map.size();
for (i=1; i<size; i++)
{
spans[i] = new String[len];
Arrays.fill(spans[i], AbstractColumnReader.BLANK_COLUMN);
}
for (i=1; i<size; i++)
{
arg = tree.get(i);
for (DEPArc arc : arg.getSHeads())
{
pred = arc.getNode();
if (!map.containsKey(pred)) continue;
predId = map.get(pred);
label = arc.getLabel();
for (int spanId : getSpan(pred, arg))
spans[spanId][predId] = label;
}
}
return spans;
}
示例3: mapPropBankToDependency
import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
void mapPropBankToDependency(String inputFile, String outputFile)
{
final String NONE = "NONE";
SRLReader reader = new SRLReader(0, 1, 2, 3, 4, 5, 6, 8);
reader.open(UTInput.createBufferedFileReader(inputFile));
PrintStream fout = UTOutput.createPrintBufferedFileStream(outputFile);
Prob2DMap map = new Prob2DMap();
DEPNode node, head;
String deprel, label, ftags;
DEPTree tree;
int i, size;
while ((tree = reader.next()) != null)
{
size = tree.size();
for (i=1; i<size; i++)
{
node = tree.get(i);
head = node.getHead();
deprel = node.getLabel();
if ((ftags = node.getFeat(DEPLib.FEAT_SEM)) != null)
deprel = ftags;
for (DEPArc arc : node.getSHeads())
{
label = arc.getLabel();
// if (label.startsWith("R-AM"))
// label = label.substring(2);
if (arc.getNode() == head)
map.add(label, deprel);
else
map.add(label, NONE);
}
}
}
List<String> keys = new ArrayList<String>(map.keySet());
DecimalFormat format = new DecimalFormat("##.##");
Collections.sort(keys);
StringDoublePair[] ps;
StringBuilder build;
double none;
String tmp;
for (String key : keys)
{
build = new StringBuilder();
ps = map.getProb1D(key);
Arrays.sort(ps);
none = 0;
for (StringDoublePair p : ps)
{
if (p.s.equals(NONE))
none = p.d;
else if (p.d >= 0.2)
{
build.append("\\d"+p.s.toUpperCase());
build.append(":");
build.append(format.format(100d*p.d));
build.append(", ");
}
}
tmp = build.length() == 0 ? "" : build.substring(0, build.length()-2);
fout.printf("%s\t%s\t%f\t%d\t%d\n", key, tmp, 100d*none, map.get(key).get(NONE), map.getTotal1D(key));
}
fout.close();
}
示例4: postLabelReferent
import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
private void postLabelReferent(DEPTree tree, List<List<DEPArc>> argLists)
{
DEPNode pred = tree.get(0);
List<DEPArc> args;
PBRoleset roleset;
String label, n;
DEPNode node;
int i, size;
DEPArc arg;
while ((pred = tree.getNextPredicate(pred.id)) != null)
{
args = argLists.get(pred.id);
size = args.size();
for (i=0; i<size; i++)
{
arg = args.get(i);
label = arg.getLabel();
if (SRLLib.P_ARG_REF.matcher(label).find())
{
if ((n = PBLib.getNumber(label)) != null && !containsNumberedArugment(args, n, 0, i) && containsNumberedArugment(args, n, i+1, size))
{
roleset = m_frames.getRoleset(getPBType(pred), pred.lemma, pred.getFeat(DEPLibEn.FEAT_PB));
n = Integer.toString(Integer.parseInt(n)+1);
if (roleset != null && roleset.isValidArgumentNumber(n) && !containsNumberedArugment(args, n, i+1, size))
{
node = arg.getNode();
if (node.getSHead(pred) != null)
node.getSHead(pred).setLabel(SRLLib.PREFIX_REFERENT+"A"+n);
}
}
break;
}
}
}
}
示例5: isInterrogative
import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
public boolean isInterrogative(DEPNode verb)
{
List<DEPArc> deps = verb.getDependents();
int i, size = deps.size();
boolean hasAux = false;
DEPNode node;
DEPArc curr;
String label;
for (i=size-1; i>=0; i--)
{
curr = deps.get(i);
node = curr.getNode();
if (node.id < verb.id || !curr.isLabel(DEPLibEn.DEP_PUNCT))
break;
else if (P_QM.matcher(node.lemma).find())
return true;
}
for (i=0; i<size; i++)
{
curr = deps.get(i);
node = curr.getNode();
label = curr.getLabel();
if (node.id < verb.id)
{
if (curr.isLabel(DEPLibEn.DEP_PRECONJ))
return false;
else if (P_AUX.matcher(label).find())
hasAux = true;
else if (node.pos.startsWith("W"))
return true;
else if (P_SBJ.matcher(label).find())
return hasAux;
}
else
break;
}
if (verb.isLemma("be") || verb.isLemma("do") || verb.isLemma("have"))
{
for (; i<size; i++)
{
curr = deps.get(i);
label = curr.getLabel();
if (P_SBJ.matcher(label).find())
return true;
}
}
return false;
}