-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
and add two additional measures
- Loading branch information
Showing
12 changed files
with
206 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package diarg.distances; | ||
|
||
import net.sf.tweety.arg.dung.syntax.Argument; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
public class CombinedDistance extends DistanceMeasure { | ||
/** | ||
* Determines the similarity between two sets of arguments, given a "base" set, using a simple similarity measure: | ||
* (|arguments in base set and in set1 and set2| + |arguments in base set and neither in set1 nor in set two|) | ||
* divided by |arguments in base set| | ||
* @param set1 Set of arguments 1 | ||
* @param set2 Set of arguments 2 | ||
* @param baseSet Base set | ||
* @return The similarity between the sets | ||
*/ | ||
@Override | ||
public double determineDistance(Collection<Argument> set1, Collection<Argument> set2, Collection<Argument> baseSet) { | ||
if (baseSet.size() == 0) { | ||
return 1; | ||
} | ||
Collection<Argument> setInAll = new ArrayList<>(); | ||
Collection<Argument> setInNone = new ArrayList<>(); | ||
for(Argument argument: baseSet) { | ||
if(set1.contains(argument) && set2.contains(argument) && baseSet.contains(argument)) { | ||
setInAll.add(argument); | ||
} else if(!set1.contains(argument) && !set2.contains(argument) && baseSet.contains(argument)){ | ||
setInNone.add(argument); | ||
} | ||
} | ||
return ((setInAll.size() + setInNone.size()) / (double) baseSet.size()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package diarg.distances; | ||
|
||
import net.sf.tweety.arg.dung.syntax.Argument; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* Abstract distance measure between sets | ||
* @author Timotheus Kampik | ||
*/ | ||
public abstract class DistanceMeasure { | ||
|
||
public abstract double determineDistance(Collection<Argument> set1, | ||
Collection<Argument> set2, | ||
Collection<Argument> baseSet); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package diarg.distances; | ||
|
||
import net.sf.tweety.arg.dung.syntax.Argument; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
public class InDistance extends DistanceMeasure { | ||
/** | ||
* Determines the similarity between two sets of arguments, given a "base" set, considering only the arguments in | ||
* the sets: | ||
* (|arguments in base set and in set1 and set2|) | ||
* divided by |arguments in base set and in either set1, set2, or both| | ||
* @param set1 Set of arguments 1 | ||
* @param set2 Set of arguments 2 | ||
* @param baseSet Base set | ||
* @return The similarity between the sets | ||
*/ | ||
@Override | ||
public double determineDistance(Collection<Argument> set1, Collection<Argument> set2, Collection<Argument> baseSet) { | ||
Collection<Argument> setInAll = new ArrayList<>(); | ||
Collection<Argument> setInSome = new ArrayList<>(); | ||
for(Argument argument: baseSet) { | ||
if(set1.contains(argument) && set2.contains(argument) && baseSet.contains(argument)) { | ||
setInAll.add(argument); | ||
setInSome.add(argument); | ||
} else if(baseSet.contains(argument) && (set1.contains(argument) || set2.contains(argument))){ | ||
setInSome.add(argument); | ||
} | ||
} | ||
if (setInSome.size() == 0) { | ||
return 1; | ||
} | ||
return setInAll.size() / (double) setInSome.size(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package diarg.distances; | ||
|
||
import net.sf.tweety.arg.dung.syntax.Argument; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
public class OutDistance extends DistanceMeasure{ | ||
/** | ||
* Determines the similarity between two sets of arguments, given a "base" set, considering only the arguments in | ||
* the sets: | ||
* (|arguments in base set and in the complements of set1 of set2 w.r.t the base set|) | ||
* divided by |arguments in base set and in either of thee complements| | ||
* @param set1 Set of arguments 1 | ||
* @param set2 Set of arguments 2 | ||
* @param baseSet Base set | ||
* @return The similarity between the sets | ||
*/ | ||
@Override | ||
public double determineDistance(Collection<Argument> set1, Collection<Argument> set2, Collection<Argument> baseSet) { | ||
Collection<Argument> setInAllComplements = new ArrayList<>(); | ||
Collection<Argument> setInSomeComplements = new ArrayList<>(); | ||
for(Argument argument: baseSet) { | ||
if(!set1.contains(argument) && !set2.contains(argument) && baseSet.contains(argument)) { | ||
setInAllComplements.add(argument); | ||
setInSomeComplements.add(argument); | ||
} else if(baseSet.contains(argument) && (!set1.contains(argument) || !set2.contains(argument))){ | ||
setInSomeComplements.add(argument); | ||
} | ||
} | ||
if (setInSomeComplements.size() == 0) { | ||
return 1; | ||
} | ||
return setInAllComplements.size() / (double) setInSomeComplements.size(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.