private static EdgeInfo buildEdgeInfo(JCas jcas, String dependencyType) { DependencyRelation relation = null; if (dependencyType != null) { relation = new DependencyRelation(dependencyType, null); } return new DefaultEdgeInfo(relation); }
protected static void createArtificialRoot(Set<Integer> roots,Map<Integer, BasicNode> id2node, Map<Integer, Integer> child2parent) { BasicNode root = new BasicNode(new DefaultInfo("EMPTY", new DefaultNodeInfo(null, null, 0, null, new DefaultSyntacticInfo(null)), new DefaultEdgeInfo(null))); int rootId = ARTIFICIAL_ROOT_ID; id2node.put(rootId,root); Iterator<Integer> it = roots.iterator(); while (it.hasNext()) { child2parent.put(it.next(),rootId); it.remove(); } roots.add(rootId); }
private EdgeInfo fromStringEdgeInfo(String str) { return new DefaultEdgeInfo(new DependencyRelation(str, null)); }
private EdgeInfo emptyEdgeInfo() { return new DefaultEdgeInfo(new DependencyRelation("", null)); }
public static ExtendedNode createNodeOfArtificialRoot() { ExtendedInfo rootInfo = new ExtendedInfo(AbstractBasicParser.ROOT_NODE_ID,new DefaultNodeInfo(null,null,0,null,new DefaultSyntacticInfo(null)),new DefaultEdgeInfo(null),ExtendedNodeConstructor.EMPTY_ADDITIONAL_NODE_INFORMATION); ExtendedNode root = new ExtendedNode(rootInfo); return root; }
public static BasicNode addArtificialRoot(BasicNode tree) { DefaultInfo rootInfo = new DefaultInfo(AbstractBasicParser.ROOT_NODE_ID,new DefaultNodeInfo(null,null,0,null,new DefaultSyntacticInfo(null)),new DefaultEdgeInfo(null)); BasicNode root = new BasicNode(rootInfo); root.addChild(tree); return root; } }
private void copyEntities() { CopyDepthLimitedTree copier1 = new CopyDepthLimitedTree(entity1, new DefaultEdgeInfo(new DependencyRelation("nsubj", DependencyRelationType.SUBJECT))); copier1.copy(Constants.DEFAULT_COPY_SUBTREE_DEPTH); entity1 = copier1.getGeneratedTree(); DsUtils.BidiMapAddAll(bidiMapOriginalToGenerated, copier1.getMapOriginalToGenerated()); CopyDepthLimitedTree copier2 = new CopyDepthLimitedTree(entity2, new DefaultEdgeInfo(new DependencyRelation("", null))); copier2.copy(Constants.DEFAULT_COPY_SUBTREE_DEPTH); entity2 = copier2.getGeneratedTree(); DsUtils.BidiMapAddAll(bidiMapOriginalToGenerated, copier2.getMapOriginalToGenerated()); }
protected BasicNode getBasicNodeFromConll(String[] toks) throws Exception { /* * items[0]: ID * items[1]: word form * items[2]: lemma * items[4]: POS * items[6]: head ID * items[7]: dependency label */ if (toks.length < 8) throw new Exception("Number of columns for each word should be at least 8: " + toks); String lemma = toks[2]; if (lemma.equals(UNKNOWN)) lemma = toks[1]; NodeInfo nodeInfo = new DefaultNodeInfo(toks[1],lemma,Integer.parseInt(toks[0]),null, new DefaultSyntacticInfo(pos.createNewPartOfSpeech(toks[4]))); EdgeInfo edgeInfo = new DefaultEdgeInfo(new DependencyRelation(toks[7],null)); Info info = new DefaultInfo(null,nodeInfo,edgeInfo); return new BasicNode(info); }
BasicConstructionNode node = new BasicConstructionNode( new DefaultInfo(nodeID.toString(), nodeInfo, new DefaultEdgeInfo(relation))); nodeID++; return node;
/** * Ctor * @throws EntailmentCompilationException */ private DefaultEntailmentRuleCompileServices() throws EntailmentCompilationException { try { PERIOD_NODE = new BasicNode(new DefaultInfo("", new DefaultNodeInfo(PERIOD, PERIOD, -1, null, new DefaultSyntacticInfo(new BySimplerCanonicalPartOfSpeech(SimplerCanonicalPosTag.PUNCTUATION))), new DefaultEdgeInfo(new DependencyRelation(StanfordDepedencyRelationType.punct.name(), null)))); } catch (UnsupportedPosTagStringException e) { throw new EntailmentCompilationException("Internal bug! could not instantiate a new UnspecifiedPartOfSpeech(SimplerCanonicalPosTag.PUNCTUATION)", e); } }
throw new ParserRunException("empty output"); BasicNode root = new BasicNode(new DefaultInfo("0",new DefaultNodeInfo("ROOT", "ROOT", 0, null, new DefaultSyntacticInfo(new StuttgartTreeTaggerPartOfSpeech("ROOT"))),new DefaultEdgeInfo(new DependencyRelation("ROOT", null)))); mapIdToNode.put(0, root); new BasicNode(new DefaultInfo(serial,new DefaultNodeInfo(lemma, lemma, id, null, new DefaultSyntacticInfo(new StuttgartTreeTaggerPartOfSpeech(pos))),new DefaultEdgeInfo(new DependencyRelation(relation, null)))); mapIdToNode.put(id, node); int parentId = Integer.parseInt(parent);
public void construct() throws UnsupportedPosTagStringException { bidiMapOriginalToGenerated = new SimpleBidirectionalMap<ExtendedNode, ExtendedNode>(); affectedNodes = new LinkedHashSet<ExtendedNode>(); copyEntities(); entity2.addChild(entity1); ExtendedNode beNode = new ExtendedNode(new ExtendedInfo( new DefaultInfo("IS_A_be", new DefaultNodeInfo("be", "be", 0, null, new DefaultSyntacticInfo(new PennPartOfSpeech(PennPosTag.VBZ))), new DefaultEdgeInfo(new DependencyRelation("cop", null))), AdditionalInformationServices.emptyInformation())); entity2.addChild(beNode); ExtendedNode punctNode = new ExtendedNode(new ExtendedInfo( new DefaultInfo("IS_A_punct", new DefaultNodeInfo(".", ".", 0, null, new DefaultSyntacticInfo(new PennPartOfSpeech("."))), new DefaultEdgeInfo(new DependencyRelation("punct", null))), AdditionalInformationServices.emptyInformation())); entity2.addChild(punctNode); generatedTree = entity2; affectedNodes.add(beNode); affectedNodes.add(punctNode); affectedNodes.add(entity1); affectedNodes.add(entity2); }
BasicNode child = new BasicNode(new DefaultInfo(DEFAULT_ID, rpNodeInfo, new DefaultEdgeInfo(new DependencyRelation("prt", null)))); ret.addChild(child); BasicNode child = new BasicNode(new DefaultInfo(DEFAULT_ID, childNodeInfo, new DefaultEdgeInfo(new DependencyRelation("nn", null)))); ret.addChild(child);
new DefaultEdgeInfo(new DependencyRelation("", null))));
nodeID.toString(), nodeAnnotatedInfo, new DefaultEdgeInfo(dr), additionalNodeInfo));
if (0==index) EdgeInfo childEdgeInfo = new DefaultEdgeInfo(new DependencyRelation(DEFAULT_RELATION_TO_PREP, null)); if (!isNode(leftPart[index])) childRelation = DEFAULT_RELATION; childEdgeInfo = new DefaultEdgeInfo(new DependencyRelation(childRelation, null));
DefaultEdgeInfo defaultEdgeInfo = new DefaultEdgeInfo(relation); DefaultSyntacticInfo syntacticInfo = new DefaultSyntacticInfo(pos); DefaultNodeInfo defaultNodeInfo = new DefaultNodeInfo(lineParser.getWord(),lineParser.getRootForm(),this.serial,null,syntacticInfo);
EdgeInfo edgeInfoForChild = new DefaultEdgeInfo(new DependencyRelation(DEFAULT_RELATION_TO_PREP, null)); if (!isNode(rightPart[index])) else childRelation = DEFAULT_RELATION; edgeInfoForChild = new DefaultEdgeInfo(new DependencyRelation(childRelation, null));
Info newInfo = new DefaultInfo(null, new DefaultNodeInfo(word, lemma, -1, null, syntacticInfo), new DefaultEdgeInfo(relation)); return newInfo;
@Override public Info supplementRightInfoWithLeftInfo(Info leftInfo, Info rightInfo) throws EntailmentCompilationException { if (leftInfo == null) throw new EntailmentCompilationException("got null left info"); if (rightInfo == null) throw new EntailmentCompilationException("got null right info"); Info alphaAnnotatedInfo = rightInfo; Info betaAnnotatedInfo = leftInfo; // choose args: alphaObj != null ? alphaObj : betaObj String lemma = (String) RuleBuildingUtils.chooseAlphaBeta(alphaAnnotatedInfo.getNodeInfo().getWordLemma(), betaAnnotatedInfo.getNodeInfo().getWordLemma()); EdgeInfo newEdgeAnnotatedInfo = new DefaultEdgeInfo( (DependencyRelation) RuleBuildingUtils.chooseAlphaBeta(alphaAnnotatedInfo.getEdgeInfo().getDependencyRelation(), betaAnnotatedInfo.getEdgeInfo().getDependencyRelation())); SyntacticInfo syntacticInfo = (SyntacticInfo) RuleBuildingUtils.chooseAlphaBeta(alphaAnnotatedInfo.getNodeInfo().getSyntacticInfo(), betaAnnotatedInfo.getNodeInfo().getSyntacticInfo()); // decide if to construct a NodeInfo or a VariableNodeAnnotatedInfo by the type of the betaNode? NodeInfo newAnnotatedNodeInfo; if (betaAnnotatedInfo.getNodeInfo().isVariable()) // copied variable nodes get the word and lemma of their lhs originals newAnnotatedNodeInfo = DefaultNodeInfo.newVariableDefaultNodeInfo (betaAnnotatedInfo.getNodeInfo().getVariableId(), null, -1, null, syntacticInfo); else { String word = (String) RuleBuildingUtils.chooseAlphaBeta(alphaAnnotatedInfo.getNodeInfo().getWord(), betaAnnotatedInfo.getNodeInfo().getWord()); newAnnotatedNodeInfo = new DefaultNodeInfo(word, lemma, -1, null, syntacticInfo); } Info newAnnotatedInfo = new DefaultInfo(betaAnnotatedInfo.getId(), newAnnotatedNodeInfo, newEdgeAnnotatedInfo); return newAnnotatedInfo; }