@Override public boolean matches(DependencyTree dependencyTree) { boolean result = false; if (!getDependencyTreeFilter().matches(dependencyTree)) { try { Feature feature = Features.getFeatureForBundle(service.listFeatures(), dependencyTree); if (feature != null) { String replacement = String.format("%s/%s", feature.getName(), feature.getVersion()); features.add(replacement); LOG.info( String.format( "Installing feature %s for maven dependency %s/%s/%s", replacement, dependencyTree.getGroupId(), dependencyTree.getArtifactId(), dependencyTree.getVersion())); result = true; } } catch (Exception e) { LOG.debug( String.format( "Unable to retrieve features information while processing dependency %s", dependencyTree.getArtifactId()), e); } } return result; }
@Test public void testProvidedDependencies() throws Exception { DependencyTreeResult node = collectDependencies("test-osgi-provided.pom"); // we exclude optional dependencies by default // DependencyTree camelSpring = assertExcludeFilter(node, "org.apache.camel", // "camel-spring", true, ""); // we exclude provided dependencies by default DependencyTree osgi = assertShareFilter(node, "org.osgi", "org.osgi.core", true, "", ""); assertEquals("getBundleId", "osgi.core", osgi.getBundleSymbolicName()); }
public static DepType getDepType(DependencyTree tree, int pIdx, int aIdx) { Bunsetsu pBun = tree.getBunsetsuFromNodeId(pIdx); Bunsetsu aBun = tree.getBunsetsuFromNodeId(aIdx); Bunsetsu pBunHeadBun = tree.getBunsetsuFromId(pBun.getHead()); Bunsetsu aBunHeadBun = tree.getBunsetsuFromId(aBun.getHead()); if (pBun.getId() == aBun.getId()) { return DepType.SAME_PHRASE; } else if (pBun.getId() == aBunHeadBun.getId()) { return DepType.DEP; } else if (pBunHeadBun.getId() == aBunHeadBun.getId()) { return DepType.DEP; } else { return DepType.ZERO_INTRA; } }
@Override protected void doInit() { DependencyTree tree = (DependencyTree) getTree(); for (DepPath c : Sequence.fromIterable(myCycles).distinct()) { Iterator<DepLink> itr = Sequence.fromIterable(c.elements()).iterator(); // skip first path element, which is always the one from my getCapturedDependencies() itr.next(); MPSTreeNode parent = this; while (itr.hasNext()) { DependencyTreeNode dtn = new DependencyTreeNode(tree.getProject(), itr.next()); parent.add(dtn); parent = dtn; } } myInitialized = true; }
/** * Creates an array of dependency trees for the given dependencies and postags of a list of * sentences. * * @param dep The dependencies describing the text, see format. * @param pos The pos tags of the text, see format. * @param p BigInteger representation of a 20 digit prime. * @param h The hash of the prime p * @return An array of DependencyTree objects. */ public static DependencyTree[] processDependency( String dep, String pos, LargeInteger p, LargeInteger h, HashAlgorithm hash) { String[] deps = fileToString(dep).split("\n\n"); String[] tags = fileToString(pos).split("\n\n"); DependencyTree[] forest = new DependencyTree[tags.length]; for (int i = 0; i < tags.length; i++) { forest[i] = DependencyTree.getInstance(deps[i], tags[i], p, h, i, hash); } return forest; }
public void resetContent( DependencyViewerScope scope, jetbrains.mps.project.Project project, boolean isMeta) { myIsMeta = isMeta; myReferencesFinder = new ReferencesFinder(); setVisible(true); myInitTree.setContent(scope, project); updateTargetsView(scope); myInitialScope = scope; myMPSProject = project; repaint(); }
public static ArgPositionType getArgPositionType(DependencyTree tree, int aIdx) { Bunsetsu aBun = tree.getBunsetsuFromNodeId(aIdx); DependencyNode aBunHeadNode = aBun.getHeadNode(); if (aIdx == aBunHeadNode.getId()) { return ArgPositionType.HEAD; } else if (aIdx == aBunHeadNode.getId() - 1) { return ArgPositionType.HEAD_LEFT; } else if (aIdx == aBunHeadNode.getId() + 1) { return ArgPositionType.HEAD_RIGHT; } else { return ArgPositionType.OTHER; } }
public static void main(String[] args) { // String file = args[0]; IntInt2IntHashMap lEr = new IntInt2IntHashMap(); HashMap<String, TObjectIntHashMap<String>> stat = new HashMap<String, TObjectIntHashMap<String>>(); try { HashSet<String> headPat = PatternFileParser.parse(new File("ipa_head_pat.txt")); HashSet<String> funcPat = PatternFileParser.parse(new File("ipa_func_pat.txt")); CaboCha2Dep pipe = new CaboCha2Dep(System.in); JapaneseDependencyTree2CaboCha caboChaOutPipe = new JapaneseDependencyTree2CaboCha(); caboChaOutPipe.setFormat(CaboChaFormat.OLD); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out, "utf-8")); while (!pipe.eof()) { DependencyTree tree = pipe.pipePerSentence(); if (tree == null) { continue; } JapaneseDependencyTreeLib.setBunsetsuHead(tree, funcPat, headPat); PredicateArgumentStructure[] pasList = tree.getPASList(); for (int j = 0; j < pasList.length; j++) { int predId = pasList[j].getPredicateId(); String predType = pasList[j].predicateType; int[] aIds = pasList[j].getIds(); String[] aLabels = pasList[j].getLabels(); for (int k = 0; k < aIds.length; k++) { DepType dt = getDepType(tree, predId, aIds[k]); ArgPositionType apt = getArgPositionType(tree, aIds[k]); if (!stat.containsKey(aLabels[k])) { stat.put(aLabels[k], new TObjectIntHashMap<String>()); } TObjectIntHashMap<String> inner = stat.get(aLabels[k]); if (!inner.containsKey(dt.toString() + ":" + apt.toString())) { inner.put(dt.toString() + ":" + apt.toString(), 0); } inner.increment(dt.toString() + ":" + apt.toString()); aLabels[k] += ":" + dt + ":" + apt; } } StringBuilder resultStr = new StringBuilder(); resultStr.append(caboChaOutPipe.pipePerSentence(tree)); writer.write(resultStr.toString()); } // print statistics for (Iterator it = stat.keySet().iterator(); it.hasNext(); ) { String key = (String) it.next(); TObjectIntHashMap inner = stat.get(key); for (TObjectIntIterator iit = inner.iterator(); iit.hasNext(); ) { iit.advance(); System.err.print(key + "\t" + iit.key() + "\t" + iit.value() + "\n"); } } } catch (IOException e) { e.printStackTrace(); } }