@Override public String toString() { StringBuilder out = new StringBuilder(""); out.append("Schema ---\n"); out.append("Word Count: ").append(words.size()).append("\n"); for (String s : words) { out.append(s).append(" "); } out.append("\n"); for (IndexWord w : indexes) { out.append(w.getLemma()).append(":").append(w.getPOS().getLabel()).append(" "); } out.append("\n"); return out.toString(); }
protected String getSpecificRelation( IndexWord word1, String term1, IndexWord word2, String term2, POS[] posES) { String relation = ""; int depth = 1110; // int depth = 1; try { List<PointerType> typesconcept1 = PointerType.getAllPointerTypesForPOS(word1.getPOS()); List<PointerType> typesconcept2 = PointerType.getAllPointerTypesForPOS(word2.getPOS()); Set<PointerType> pointersSet = new HashSet<PointerType>(); pointersSet.addAll(typesconcept1); pointersSet.addAll(typesconcept2); Synset[] concept1Synsets = word1.getSenses(); // Synset concept1Synset = concept1Synsets[0]; Synset[] concept2Synsets = word2.getSenses(); // Synset concept2Synset = concept2Synsets[0]; List<PointerType> pts = PointerType.getAllPointerTypes(); if (concept1Synsets != null && concept2Synsets != null) { Set<Relationship> relsSet = new HashSet<Relationship>(); for (int i = 0; i < concept1Synsets.length; i++) { Synset concept1Synset, concept2Synset; if (isSynsetOfPOS(concept1Synsets[i], posES) && isTermContainedInWords(concept1Synsets[i], term1)) { concept1Synset = concept1Synsets[i]; for (int j = 0; j < concept2Synsets.length; j++) if (isSynsetOfPOS(concept2Synsets[j], posES) && isTermContainedInWords(concept2Synsets[i], term2)) { concept2Synset = concept2Synsets[j]; for (PointerType pt : pts) { // RelationshipList list = relationFinder.findRelationships(concept1Synset, // concept2Synset, pt); RelationshipList list = relationFinder.findRelationships( concept1Synset, concept2Synset, pt, RELATIONSHIP_DEEP); if (list != null && !list.isEmpty()) { Relationship rel = list.getShallowest(); if (rel.getDepth() < depth) depth = rel.getDepth(); relsSet.add(rel); list.clear(); list = null; } } } } } relation = getRelevantRelation(relsSet, depth); } } catch (JWNLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return relation; }