Skip to content

Commit

Permalink
The LinkSpecification expression now gets printed into the statistics…
Browse files Browse the repository at this point in the history
… file
  • Loading branch information
becker-al committed Aug 7, 2024
1 parent c5ef096 commit b8d95fd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,11 @@ static LimesResult getMapping(Configuration config, int limit, ActiveLearningOra
+ " (need verification) = " + results.size() + " (total)");

//LSVerbalization
LinkSpecification resultLinkSpec = isAlgorithm ? results.getLinkSpecification() : new LinkSpecification(config.getMetricExpression(), config.getAcceptanceThreshold());
Map<String, String> lsVerbalizationByLanguage = LSVerbalization.getLSVerbalizationByLanguage(config.getExplainLS(),
isAlgorithm ? results.getLinkSpecification() : new LinkSpecification(config.getMetricExpression(), config.getAcceptanceThreshold()));
resultLinkSpec);

return new LimesResult(verificationMapping, acceptanceMapping, sourceCache, targetCache, runTime, lsVerbalizationByLanguage);
return new LimesResult(verificationMapping, acceptanceMapping, sourceCache, targetCache, runTime, lsVerbalizationByLanguage, resultLinkSpec);
}

private static void writeResults(LimesResult mappings, Configuration config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.aksw.limes.core.evaluation.qualititativeMeasures.FMeasure;
import org.aksw.limes.core.evaluation.qualititativeMeasures.PseudoFMeasure;
import org.aksw.limes.core.io.cache.ACache;
import org.aksw.limes.core.io.ls.LinkSpecification;
import org.aksw.limes.core.io.mapping.AMapping;
import org.aksw.limes.core.io.mapping.MappingFactory;
import org.aksw.limes.core.measures.mapper.MappingOperations;
Expand All @@ -39,6 +40,7 @@ public class LimesResult {
private ACache targetCache = null;
private long runTime = 0;
private Map<String, String> lsVerbalization = null; //Language->Verbalization Map
private LinkSpecification linkSpecification;

/**
* Constructor
Expand All @@ -50,8 +52,9 @@ public class LimesResult {

/**
* Constructor
*
* @param verificationMapping Mapping where acceptanceThreshold &gt; sim &gt;= verificationThreshold
* @param acceptanceMapping Mapping where sim &gt;= acceptanceThreshold
* @param acceptanceMapping Mapping where sim &gt;= acceptanceThreshold
*/
public LimesResult(AMapping verificationMapping, AMapping acceptanceMapping) {
super();
Expand All @@ -62,24 +65,27 @@ public LimesResult(AMapping verificationMapping, AMapping acceptanceMapping) {

/**
* Constructor
*
* @param verificationMapping Mapping where acceptanceThreshold &gt; sim &gt;= verificationThreshold
* @param acceptanceMapping Mapping where sim &gt;= acceptanceThreshold
* @param sourceCache source resources cache
* @param targetCache target resources cache
* @param runTime run time
* @param lsVerbalization A natural language explanation of the metric grouped by language
* @param acceptanceMapping Mapping where sim &gt;= acceptanceThreshold
* @param sourceCache source resources cache
* @param targetCache target resources cache
* @param runTime run time
* @param lsVerbalization A natural language explanation of the metric grouped by language
*/
public LimesResult(AMapping verificationMapping, AMapping acceptanceMapping, ACache sourceCache, ACache targetCache, long runTime, Map<String, String> lsVerbalization) {
public LimesResult(AMapping verificationMapping, AMapping acceptanceMapping, ACache sourceCache, ACache targetCache, long runTime, Map<String, String> lsVerbalization, LinkSpecification linkSpecification) {
this(verificationMapping, acceptanceMapping);
this.sourceCache = sourceCache;
this.targetCache = targetCache;
this.runTime = runTime;
this.lsVerbalization = lsVerbalization;
this.linkSpecification = linkSpecification;
}


/**
* Getter for verification part
*
* @return verification mapping
*/
public AMapping getVerificationMapping() {
Expand All @@ -89,6 +95,7 @@ public AMapping getVerificationMapping() {

/**
* Getter for acceptance part
*
* @return acceptance mapping
*/
public AMapping getAcceptanceMapping() {
Expand Down Expand Up @@ -140,11 +147,12 @@ public String getStatistics() {
"\n\t\t\t\"recall\" : %s," +
"\n\t\t\t\"f-measure\" : %s" +
"\n\t\t}" +
"\n\t}",
this.runTime, this.sourceCache.size(), this.targetCache.size(),
"\n\t}," +
"\n\t\"linkSpecification\" : \"%s\"",
this.runTime, this.sourceCache.size(), this.targetCache.size(),
this.verificationMapping.size(), this.acceptanceMapping.size(),
Double.toString(pseudoPrecisionForAcceptance), Double.toString(pseudoRecallForAcceptance), Double.toString(pseudoFMeasureForAcceptance),
Double.toString(pseudoPrecisionForAll), Double.toString(pseudoRecallForAll), Double.toString(pseudoFMeasureForAll));
Double.toString(pseudoPrecisionForAll), Double.toString(pseudoRecallForAll), Double.toString(pseudoFMeasureForAll), linkSpecification.getFullExpression());
return formatted + lsVerbalizationString +
"\n}";
}
Expand All @@ -166,7 +174,7 @@ private AMapping filterReferenceCompliant(AMapping input, Set<String> referenceS

public String getStatistics(AMapping reference) {
String stats = getStatistics();
stats = stats.substring(0, stats.length()-2);
stats = stats.substring(0, stats.length() - 2);
Set<String> gsS = reference.getMap().keySet();
Set<String> gsT = new HashSet<>();
for (String s : reference.getMap().keySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,8 @@ public LinkSpecification() {
/**
* Creates a spec with a measure read inside
*
* @param measure
* String representation of the spec
* @param threshold
* of the spec
* @param measure String representation of the spec
* @param threshold of the spec
*/
public LinkSpecification(String measure, double threshold) {
setOperator(null);
Expand All @@ -104,8 +102,7 @@ public void setAtomicFilterExpression(String atomicMeasure, String prop1, String
/**
* Adds a child to the current node of the spec
*
* @param spec
* to be added
* @param spec to be added
*/
public void addChild(LinkSpecification spec) {
if (getChildren() == null)
Expand All @@ -116,8 +113,7 @@ public void addChild(LinkSpecification spec) {
/**
* Adds a child to the current node of the spec
*
* @param spec
* to be added
* @param spec to be added
*/
public void addDependency(LinkSpecification spec) {
if (getDependencies() == null)
Expand All @@ -128,8 +124,7 @@ public void addDependency(LinkSpecification spec) {
/**
* Removes a dependency from the list of dependencies
*
* @param spec
* Input spec
* @param spec Input spec
*/
public void removeDependency(LinkSpecification spec) {
if (getDependencies().contains(spec)) {
Expand Down Expand Up @@ -195,10 +190,8 @@ public void pathOfAtomic() {
* the filters by checking (if threshold_left and threshold_right grater
* than or equal to theta, then theta = 0)
*
* @param spec
* expression to read
* @param theta
* Global threshold
* @param spec expression to read
* @param theta Global threshold
*/
public void readSpec(String spec, double theta) {
spec = spec.trim();
Expand Down Expand Up @@ -595,8 +588,7 @@ public String getAtomicMeasure() {
}

/**
* @param atomicMeasure
* the atomicMeasure to set
* @param atomicMeasure the atomicMeasure to set
*/
public void setAtomicMeasure(String atomicMeasure) {
this.atomicMeasure = atomicMeasure;
Expand Down

0 comments on commit b8d95fd

Please sign in to comment.