diff --git a/src/main/java/com/gessi/dependency_detection/components/Dependency.java b/src/main/java/com/gessi/dependency_detection/components/Dependency.java index 5261343..064c7f9 100644 --- a/src/main/java/com/gessi/dependency_detection/components/Dependency.java +++ b/src/main/java/com/gessi/dependency_detection/components/Dependency.java @@ -49,4 +49,23 @@ public DependencyType getDependencyType() { return dependencyType; } + @Override + public boolean equals(Object o) { + + if (o instanceof Dependency){ + Dependency dep = (Dependency) o; + return (dep.getFrom().equals(this.from) && dep.getTo().equals(this.to) && dep.getDependencyType().equals(this.dependencyType)); + } + + return false; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 17 * hash + (this.to != null ? this.to.hashCode() : 0) + (this.from != null ? this.from.hashCode() : 0) + + (this.dependencyType != null ? this.dependencyType.hashCode() : 0); + return hash; + } + } diff --git a/src/main/java/com/gessi/dependency_detection/functionalities/OntologyHandler.java b/src/main/java/com/gessi/dependency_detection/functionalities/OntologyHandler.java index 81ece8b..cfd0f39 100644 --- a/src/main/java/com/gessi/dependency_detection/functionalities/OntologyHandler.java +++ b/src/main/java/com/gessi/dependency_detection/functionalities/OntologyHandler.java @@ -215,9 +215,9 @@ public void matching(String keywords, String reqId, String requirement, boolean for (int j = 0; j < ontClasses.size(); j++) { lemmas = classesLemmas.get(j); if (keywords.split(" ").length >= lemmas.length && extractNGram(keywords, lemmas, syny,thr,wordEmbedding)) { - System.out.println("A MATCH WAS MADE BETWEEN:"); - System.out.println("REQUIREMENT KEYWORDS: "+keywords); - System.out.println("ONTOLOGY NAME: "+lemmas.toString()); + System.out.println("Requirement " + reqId + " contains class " + String.join(" ", lemmas)); + //System.out.println("REQUIREMENT KEYWORDS: "+keywords); + //System.out.println("ONTOLOGY NAME: "+lemmas.toString()); classes.add(ontClasses.get(j)); } @@ -225,7 +225,7 @@ public void matching(String keywords, String reqId, String requirement, boolean // Requirement instantiation within the ontology for (OntClass cls : classes) { - System.out.println("A MATCH WAS MADE"); + //System.out.println("A MATCH WAS MADE"); Individual individual = this.model.createIndividual(this.source + ":" + reqId + "_" + cls.getLocalName(), cls); DatatypeProperty req = this.model.getDatatypeProperty(this.source + "#requirement"); @@ -307,7 +307,7 @@ public List ontConflictDetection() { if (!f.equals(t)) { Dependency newDep = new Dependency(f, t, Status.PROPOSED, DependencyType.valueOf((String) dep.get(0).toString().toUpperCase())); - dependencies.add(newDep); + if (!dependencies.contains(newDep)) dependencies.add(newDep); } } } diff --git a/src/main/resources/ExcludedWords.txt b/src/main/resources/ExcludedWords.txt index e8ba81a..48b8841 100644 --- a/src/main/resources/ExcludedWords.txt +++ b/src/main/resources/ExcludedWords.txt @@ -718,7 +718,6 @@ every ere each et -etc elsewhere else ex