本文整理汇总了Java中net.didion.jwnl.data.list.PointerTargetNodeList.get方法的典型用法代码示例。如果您正苦于以下问题:Java PointerTargetNodeList.get方法的具体用法?Java PointerTargetNodeList.get怎么用?Java PointerTargetNodeList.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.didion.jwnl.data.list.PointerTargetNodeList
的用法示例。
在下文中一共展示了PointerTargetNodeList.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVerbGroup
import net.didion.jwnl.data.list.PointerTargetNodeList; //导入方法依赖的package包/类
/** Get the group that this verb belongs to. */
public PointerTargetNodeList getVerbGroup(Synset synset) throws JWNLException {
// We need to go through all this hastle because
// 1. a verb does not always have links to all the verbs in its group
// 2. two verbs in the same group sometimes have reciprocal links, and we want
// to make sure that each verb synset appears in the final list only once
PointerTargetNodeList nodes = new PointerTargetNodeList();
nodes.add(new PointerTargetNode(synset, PointerType.VERB_GROUP));
int maxIndex = 0;
int index = -1;
do {
index++;
PointerTargetNode node = (PointerTargetNode) nodes.get(index);
for (Iterator itr = getPointerTargets(node.getSynset(), PointerType.VERB_GROUP).iterator(); itr.hasNext();) {
PointerTargetNode testNode = (PointerTargetNode) itr.next();
if (!nodes.contains(testNode)) {
nodes.add(testNode);
maxIndex++;
}
}
} while (index < maxIndex);
return nodes;
}
示例2: getSynsets
import net.didion.jwnl.data.list.PointerTargetNodeList; //导入方法依赖的package包/类
/**
* Looks up the synsets that correspond to the nodes in a node list.
*
* @param nodes node list
* @return synsets
*/
private static Synset[] getSynsets(PointerTargetNodeList nodes) {
Synset[] synsets = new Synset[nodes.size()];
for (int i = 0; i < nodes.size(); i++) {
PointerTargetNode node = (PointerTargetNode) nodes.get(i);
synsets[i] = node.getSynset();
}
return synsets;
}
示例3: findAsymmetricRelationship
import net.didion.jwnl.data.list.PointerTargetNodeList; //导入方法依赖的package包/类
/**
* Find a relationship between two asymmetric lists ordered from deepest
* to shallowest ancestor. Each node has it's PointerType set to the kind of
* relationship one need to follow to get from it to the next node in the list.
* Take the dog/cat relationship. To get to carnivore, a hypernym relationship
* must be used to get from dog to carnivore, but then a hyponym relationship
* must be used to get from carnivore to cat. The list will look like this:
* dog(hyper) -> canine(hyper) -> carnivore(hypo) -> feline(hypo) -> cat(hypo).
* In this instance, cat's PointerType is meaningless, but is kept to facilitate
* things like reversing the relationship (which just involves setting each node's
* pointer type to the symmetric type of its current type.
*/
private Relationship findAsymmetricRelationship(
PointerTargetNodeList sourceNodes, PointerTargetNodeList targetNodes,
PointerType type, Synset sourceSynset, Synset targetSynset) {
// If the deepest ancestors of the words are not the same,
// then there is no relationship between the words.
if (!sourceNodes.get(0).equals(targetNodes.get(0))) return null;
PointerTargetNodeList relationship = new PointerTargetNodeList();
int targetStart = 0;
int commonParentIndex = 0;
for (int i = sourceNodes.size() - 1; i >= 0; i--) {
PointerTargetNode testNode = (PointerTargetNode)sourceNodes.get(i);
int idx = targetNodes.indexOf(testNode);
if (idx >= 0) {
targetStart = idx;
break;
} else {
relationship.add(testNode.clone());
commonParentIndex++;
}
}
for (int i = targetStart; i < targetNodes.size(); i++) {
PointerTargetNode node = (PointerTargetNode)((PointerTargetNode)targetNodes.get(i)).clone();
node.setType(type.getSymmetricType());
relationship.add(node);
}
return new AsymmetricRelationship(type, relationship, commonParentIndex, sourceSynset, targetSynset);
}