Revision: 9735
http://languagetool.svn.sourceforge.net/languagetool/?rev=9735&view=rev
Author: dnaber
Date: 2013-03-19 22:19:41 +0000 (Tue, 19 Mar 2013)
Log Message:
-----------
online check: display complete sentence, not just context; hover over word
displays POS tags
Modified Paths:
--------------
trunk/languagetool/languagetool-wikipedia/src/main/java/org/languagetool/dev/index/MatchingSentence.java
trunk/languagetool/languagetool-wikipedia/src/main/java/org/languagetool/dev/index/Searcher.java
trunk/ltcommunity/grails-app/views/ruleEditor/_corpusResult.gsp
Modified:
trunk/languagetool/languagetool-wikipedia/src/main/java/org/languagetool/dev/index/MatchingSentence.java
===================================================================
---
trunk/languagetool/languagetool-wikipedia/src/main/java/org/languagetool/dev/index/MatchingSentence.java
2013-03-19 21:35:17 UTC (rev 9734)
+++
trunk/languagetool/languagetool-wikipedia/src/main/java/org/languagetool/dev/index/MatchingSentence.java
2013-03-19 22:19:41 UTC (rev 9735)
@@ -20,6 +20,7 @@
import java.util.List;
+import org.languagetool.AnalyzedSentence;
import org.languagetool.rules.RuleMatch;
/**
@@ -28,10 +29,12 @@
public class MatchingSentence {
private final String sentence;
+ private final AnalyzedSentence analyzedSentence;
private final List<RuleMatch> ruleMatches;
- MatchingSentence(String sentence, List<RuleMatch> ruleMatches) {
+ MatchingSentence(String sentence, AnalyzedSentence analyzedSentence,
List<RuleMatch> ruleMatches) {
this.sentence = sentence;
+ this.analyzedSentence = analyzedSentence;
this.ruleMatches = ruleMatches;
}
@@ -39,6 +42,10 @@
return sentence;
}
+ public AnalyzedSentence getAnalyzedSentence() {
+ return analyzedSentence;
+ }
+
public List<RuleMatch> getRuleMatches() {
return ruleMatches;
}
Modified:
trunk/languagetool/languagetool-wikipedia/src/main/java/org/languagetool/dev/index/Searcher.java
===================================================================
---
trunk/languagetool/languagetool-wikipedia/src/main/java/org/languagetool/dev/index/Searcher.java
2013-03-19 21:35:17 UTC (rev 9734)
+++
trunk/languagetool/languagetool-wikipedia/src/main/java/org/languagetool/dev/index/Searcher.java
2013-03-19 22:19:41 UTC (rev 9735)
@@ -30,6 +30,7 @@
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.SimpleFSDirectory;
import org.apache.lucene.util.Counter;
+import org.languagetool.AnalyzedSentence;
import org.languagetool.JLanguageTool;
import org.languagetool.Language;
import org.languagetool.rules.Rule;
@@ -223,7 +224,8 @@
final String sentence = doc.get(FIELD_NAME);
final List<RuleMatch> ruleMatches = languageTool.check(sentence);
if (ruleMatches.size() > 0) {
- final MatchingSentence matchingSentence = new
MatchingSentence(sentence, ruleMatches);
+ final AnalyzedSentence analyzedSentence =
languageTool.getAnalyzedSentence(sentence);
+ final MatchingSentence matchingSentence = new
MatchingSentence(sentence, analyzedSentence, ruleMatches);
matchingSentences.add(matchingSentence);
}
}
Modified: trunk/ltcommunity/grails-app/views/ruleEditor/_corpusResult.gsp
===================================================================
--- trunk/ltcommunity/grails-app/views/ruleEditor/_corpusResult.gsp
2013-03-19 21:35:17 UTC (rev 9734)
+++ trunk/ltcommunity/grails-app/views/ruleEditor/_corpusResult.gsp
2013-03-19 22:19:41 UTC (rev 9735)
@@ -21,7 +21,8 @@
<g:if test="${searcherResult.getMatchingSentences().size() == limit}">
(showing only the first ${limit} matches)
</g:if>
- Please consider modifying your rule if these matches are false alarms.
+ Please consider modifying your rule if these matches are false alarms.
Hover over the
+ words to display their part-of-speech tags:
<g:if test="${!expertMode}">
As this page does not support our full rule syntax you might want
to learn
more in <a target="devdocumentation"
href="http://www.languagetool.org/development/">our development
@@ -33,10 +34,22 @@
<g:each in="${searcherResult.getMatchingSentences()}"
var="matchingSentence">
<g:each in="${matchingSentence.getRuleMatches()}" var="match">
<li>
- <span
class="exampleSentence">${org.languagetool.gui.Tools.getContext(
- match.getFromPos(), match.getToPos(),
- matchingSentence.getSentence(),
- 100, "<span class='errorMarker'>", "</span>",
true)}</span>
+ <g:set var="pos" value="${0}"/>
+ <g:set var="startMarked" value="${false}"/>
+ <g:set var="endMarked" value="${false}"/>
+ <g:each
in="${matchingSentence.getAnalyzedSentence().getTokens()}" var="token">
+ <g:if test="${pos >= match.getFromPos() &&
!startMarked}">
+ <span class='errorMarker'>
+ <g:set var="startMarked" value="${true}"/>
+ </g:if>
+ <span
title="${token.getReadings().encodeAsHTML()}">${token.getToken().encodeAsHTML()}</span>
+ <g:if test="${pos >= match.getToPos() &&
!endMarked}"></span>
+ <g:set var="endMarked" value="${true}"/>
+ </g:if>
+ <%
+ pos += token.getToken().length();
+ %>
+ </g:each>
</li>
</g:each>
</g:each>
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits