use of com.joliciel.talismane.posTagger.PosTaggedToken in project talismane by joliciel-informatique.
the class ParseConfiguration method getHead.
/**
* Get the head of a given pos-tagged token in the current set of
* dependencies, or null if none exists.
*
* @param dependent
* the token whose governing arc we want
* @param projective
* if true, consider projective set, if false consider non-projective
* set.
*/
public PosTaggedToken getHead(PosTaggedToken dependent, boolean projective) {
DependencyArc arc = this.getGoverningDependency(dependent, projective);
PosTaggedToken head = null;
if (arc != null)
head = arc.getHead();
return head;
}
use of com.joliciel.talismane.posTagger.PosTaggedToken in project talismane by joliciel-informatique.
the class ParseConfiguration method addDependency.
/**
* @param arc
* @throws CircularDependencyException
* if this would create a circular dependency.
*/
void addDependency(DependencyArc arc) throws CircularDependencyException {
PosTaggedToken ancestor = arc.getHead();
while (ancestor != null) {
if (ancestor.equals(arc.getDependent())) {
throw new CircularDependencyException(this, arc.getHead(), arc.getDependent());
}
ancestor = this.getHead(ancestor);
}
this.dependencies.add(arc);
this.governingDependencyMap[arc.getDependent().getIndex()] = arc;
this.governorMap[arc.getDependent().getIndex()] = arc.getHead().getIndex();
this.labelMap[arc.getDependent().getIndex()] = arc.getLabel();
if (LOG.isTraceEnabled()) {
LOG.trace("Added arc: " + arc);
LOG.trace("dependencies: " + this.dependencies);
LOG.trace("governingDependencyMap: " + this.governingDependencyMap);
}
}
use of com.joliciel.talismane.posTagger.PosTaggedToken in project talismane by joliciel-informatique.
the class ParseTreeNode method getEdgeCount.
/**
* Non-projectivity: for each edge directly governed by this node, counts the
* number of connected components contained inside the interval defined by the
* edge, which are not themselves dominated by this node, i.e. not contained
* in the node's yield. A connected component is a connected subtree. Returns
* the maximum edge count.
*/
public int getEdgeCount() {
List<DependencyArc> nonProjectiveEdges = new ArrayList<>();
this.getMyNonProjectiveEdges(nonProjectiveEdges);
List<DependencyArc> gapHeads = this.getGapHeads();
int maxEdgeCount = 0;
for (DependencyArc nonProjectiveEdge : nonProjectiveEdges) {
int edgeCount = 0;
PosTaggedToken child = nonProjectiveEdge.getDependent();
int i = this.getIndex() < child.getIndex() ? this.getIndex() : child.getIndex();
int j = this.getIndex() > child.getIndex() ? this.getIndex() : child.getIndex();
for (DependencyArc gapHead : gapHeads) {
if (gapHead.getDependent().getIndex() > i && gapHead.getDependent().getIndex() < j)
edgeCount++;
}
if (edgeCount > maxEdgeCount)
maxEdgeCount = edgeCount;
}
return maxEdgeCount;
}
use of com.joliciel.talismane.posTagger.PosTaggedToken in project talismane by joliciel-informatique.
the class DependencyNode method isContiguous.
/**
* Return true if this node is contiguous, false if it contains gaps.
*/
public boolean isContiguous() {
Set<PosTaggedToken> yield = this.getYield();
int currentIndex = -1;
boolean contiguous = true;
for (PosTaggedToken token : yield) {
if (currentIndex < 0) {
currentIndex = token.getIndex();
} else if (token.getIndex() == currentIndex + 1) {
currentIndex++;
} else {
contiguous = false;
break;
}
}
return contiguous;
}
use of com.joliciel.talismane.posTagger.PosTaggedToken in project talismane by joliciel-informatique.
the class DependencyNode method autoPopulate.
/**
* Populate this node's dependents directly from the parse configuration.
*/
public void autoPopulate() {
for (PosTaggedToken dependent : parseConfiguration.getDependents(this.token)) {
DependencyNode childNode;
try {
childNode = this.addDependent(dependent);
} catch (TalismaneException e) {
// should never happen
LOG.error(e.getMessage(), e);
throw new RuntimeException(e);
}
childNode.autoPopulate();
}
}
Aggregations