-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Aligned the length implementation to the definition in the related work.
- Loading branch information
1 parent
3e6ef41
commit 2faae5b
Showing
2 changed files
with
31 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,25 +8,22 @@ | |
|
||
public class LengthBasedRefinementScorer extends AbstractScoreCalculatorDecorator { | ||
|
||
protected double propertyPenalty = 0.01; | ||
protected double junctionPenalty = 0.005; | ||
protected double lengthPenalty = 0.01; | ||
|
||
public LengthBasedRefinementScorer(ScoreCalculator decorated) { | ||
super(decorated); | ||
} | ||
|
||
public LengthBasedRefinementScorer(ScoreCalculator decorated, double propertyPenalty, double junctionPenalty) { | ||
public LengthBasedRefinementScorer(ScoreCalculator decorated, double lengthPenalty) { | ||
super(decorated); | ||
this.propertyPenalty = propertyPenalty; | ||
this.junctionPenalty = junctionPenalty; | ||
this.lengthPenalty = lengthPenalty; | ||
} | ||
|
||
@Override | ||
public double calculateRefinementScore(int posCount, int negCount, double classificationScore, ClassExpression ce) { | ||
LengthDetectingVisitor visitor = new LengthDetectingVisitor(); | ||
ce.accept(visitor); | ||
return classificationScore | ||
- ((visitor.propertyCount * propertyPenalty) + (visitor.junctionMemberCount * junctionPenalty)); | ||
return classificationScore - (visitor.length * lengthPenalty); | ||
} | ||
|
||
public static class Factory implements ScoreCalculatorFactory { | ||
|
@@ -43,77 +40,44 @@ public ScoreCalculator create(int numOfPositives, int numOfNegatives) { | |
} | ||
} | ||
|
||
/** | ||
* Length as defined in "Learning Concept Lengths Accelerates Concept Learning | ||
* in ALC" | ||
* | ||
* @author Michael Röder ([email protected]) | ||
* | ||
*/ | ||
public static class LengthDetectingVisitor implements ClassExpressionVisitor { | ||
|
||
protected int junctionCount = 0; | ||
protected int junctionMemberCount = 0; | ||
protected int propertyCount = 0; | ||
protected int length = 0; | ||
|
||
public LengthDetectingVisitor() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public void visitNamedClass(NamedClass node) { | ||
if (node.isNegated()) { | ||
length += 2; | ||
} else { | ||
length += 1; | ||
} | ||
} | ||
|
||
@Override | ||
public void visitJunction(Junction node) { | ||
this.junctionCount++; | ||
this.junctionMemberCount += node.getChildren().size(); | ||
length += 1; | ||
for (ClassExpression child : node.getChildren()) { | ||
child.accept(this); | ||
} | ||
} | ||
|
||
@Override | ||
public void visitSimpleQuantificationRole(SimpleQuantifiedRole node) { | ||
this.propertyCount++; | ||
length += 2; | ||
node.getTailExpression().accept(this); | ||
} | ||
|
||
/** | ||
* @return the junctionCount | ||
*/ | ||
public int getJunctionCount() { | ||
return junctionCount; | ||
} | ||
|
||
/** | ||
* @param junctionCount the junctionCount to set | ||
*/ | ||
public void setJunctionCount(int junctionCount) { | ||
this.junctionCount = junctionCount; | ||
} | ||
|
||
/** | ||
* @return the junctionMemberCount | ||
*/ | ||
public int getJunctionMemberCount() { | ||
return junctionMemberCount; | ||
} | ||
|
||
/** | ||
* @param junctionMemberCount the junctionMemberCount to set | ||
*/ | ||
public void setJunctionMemberCount(int junctionMemberCount) { | ||
this.junctionMemberCount = junctionMemberCount; | ||
} | ||
|
||
/** | ||
* @return the propertyCount | ||
*/ | ||
public int getPropertyCount() { | ||
return propertyCount; | ||
} | ||
|
||
/** | ||
* @param propertyCount the propertyCount to set | ||
*/ | ||
public void setPropertyCount(int propertyCount) { | ||
this.propertyCount = propertyCount; | ||
} | ||
|
||
} | ||
|
||
} |
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