Skip to content

Commit

Permalink
#34 - Improve and refactor Active Learning code
Browse files Browse the repository at this point in the history
- Improved error handling
- Further condensed code
- Show a bit of context in the recommentation text area (mainly for debugging purposes)
- Smaller labels (confidence -> score; difference -> delta)
  • Loading branch information
reckart committed Apr 11, 2018
1 parent 3e78af0 commit fe57c99
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public boolean hasRecommendationWhichIsSkipped()
return !listOfRecommendationsForEachToken.isEmpty();
}

public void getRecommendationFromRecommendationModel()
private void getRecommendationFromRecommendationModel()
{
Predictions model = recommendationService.getPredictions(annotatorState.getUser(),
annotatorState.getProject());
Expand All @@ -119,13 +119,12 @@ private void getRecommendationsForThisDocument(Predictions model, JCas aJcas) {
}

private void getRecommendationsForWholeProject(Predictions model) {
listOfRecommendationsForEachToken = new ArrayList();
listOfRecommendationsForEachToken = new ArrayList<>();

if (model != null) {
Map<String, List<List<AnnotationObject>>> recommendationsMap = model
.getPredictionsForWholeProject(selectedLayer, documentService);


Set<String> documentNameSet = recommendationsMap.keySet();

for (String documentName : documentNameSet) {
Expand Down Expand Up @@ -427,11 +426,12 @@ private ArrayList<Integer> storeExistingAnnotationsSpanBegin(Iterator existingAn
return existingAnnotationsSpanBegin;
}

public boolean checkRecommendationExist(DocumentService documentService, LearningRecord record)
public boolean checkRecommendationExist(DocumentService aDocumentService,
LearningRecord aRecord)
{
this.documentService = documentService;
documentService = aDocumentService;
getRecommendationFromRecommendationModel();
return containSuggestion(record);
return containSuggestion(aRecord);
}

public boolean containSuggestion(LearningRecord record) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ <h3 class="panel-title">Session</h3>
</div>
</form>

<div class="panel panel-default panel-small">
<span class="col-sm-12" wicket:id="noRecommendationLabel"> no Recommendation</span>
<div class="panel panel-default panel-small" wicket:enclosure="noRecommendationLabel">
<span class="col-sm-12" wicket:id="noRecommendationLabel">no Recommendation</span>
</div>

<form class="panel panel-default panel-small" wicket:id="learnFromSkippedRecommendationForm">
<span class="col-sm-12" wicket:id="onlySkippedRecommendationLabel"> learnSkippedOnes</span>
<span class="col-sm-12" wicket:id="onlySkippedRecommendationLabel">learnSkippedOnes</span>
<div class="panel-footer text-right">
<input type="submit" class="btn btn-success" wicket:id="learnSkippedOnes" value="Yes"/>
</div>
Expand All @@ -61,7 +61,7 @@ <h3 class="panel-title">Recommendation</h3>
<label class="col-sm-3 control-label">Text</label>
<div class="col-sm-9" style="position: relative; height: 5em;">
<div class="form-control"
style="overflow-y: auto; width: unset; word-wrap: break-word; height: 5em; position: absolute; top: 0; left: 15px; right: 15px;"
style="overflow-y: auto; width: unset; word-wrap: break-word; height: 5em; position: absolute; top: 0; left: 10px; right: 10px;"
readonly>
<a wicket:id="recommendationCoveredTextLink"></a>
</div>
Expand All @@ -74,22 +74,22 @@ <h3 class="panel-title">Recommendation</h3>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Confidence</label>
<label class="col-sm-3 control-label">Score</label>
<div class="col-sm-9">
<span class="form-control" wicket:id="recommendedConfidence"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Difference</label>
<label class="col-sm-3 control-label">Delta</label>
<div class="col-sm-9">
<span class="form-control" wicket:id="recommendedDifference"></span>
</div>
</div>
</div>
<div class="panel-footer text-right">
<input type="submit" class="btn btn-success" wicket:id="acceptButton" value="Accept"/>
<input type="submit" class="btn btn-danger" wicket:id="rejectButton" value="Reject"/>
<input type="submit" class="btn btn-warning" wicket:id="skipButton" value="Skip"/>
<input type="button" class="btn btn-success" wicket:id="acceptButton" value="Accept"/>
<input type="button" class="btn btn-danger" wicket:id="rejectButton" value="Reject"/>
<input type="button" class="btn btn-warning" wicket:id="skipButton" value="Skip"/>
</div>
</form>

Expand Down
Loading

0 comments on commit fe57c99

Please sign in to comment.