Revision: 5929
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=5929&view=rev
Author:   dnaber
Date:     2011-11-18 22:51:24 +0000 (Fri, 18 Nov 2011)
Log Message:
-----------
filter the Wikipedia matches by rule type

Modified Paths:
--------------
    
trunk/ltcommunity/grails-app/controllers/org/languagetool/CorpusMatchController.groovy
    trunk/ltcommunity/grails-app/i18n/messages.properties
    trunk/ltcommunity/grails-app/views/corpusMatch/list.gsp

Modified: 
trunk/ltcommunity/grails-app/controllers/org/languagetool/CorpusMatchController.groovy
===================================================================
--- 
trunk/ltcommunity/grails-app/controllers/org/languagetool/CorpusMatchController.groovy
      2011-11-18 22:17:42 UTC (rev 5928)
+++ 
trunk/ltcommunity/grails-app/controllers/org/languagetool/CorpusMatchController.groovy
      2011-11-18 22:51:24 UTC (rev 5929)
@@ -43,13 +43,36 @@
 
     def list = {
       if(!params.max) params.max = 10
+      if(!params.offset) params.offset = 0
       String langCode = "en"
       if (params.lang) {
-          langCode = params.lang
+        langCode = params.lang
       }
+      // Grouped Overview of Rule Matches:
+      def matchByRuleCriteria = CorpusMatch.createCriteria()
+      def matchesByRule = matchByRuleCriteria {
+        eq('languageCode', langCode)
+        projections {
+          groupProperty("ruleID")
+          count("ruleID")
+        }
+        order("ruleID")
+      }
+      // Rule Matches for this language:
+      def matchCriteria = CorpusMatch.createCriteria()
+      def matches = matchCriteria {
+        if (params.filter) {
+          eq('ruleID', params.filter)
+        }
+        eq('languageCode', langCode)
+        eq('isVisible', true)
+        firstResult(params.offset)
+        maxResults(params.max)
+      }
       int totalMatches = CorpusMatch.countByLanguageCodeAndIsVisible(langCode, 
true)
-      [ corpusMatchList: 
CorpusMatch.findAllByLanguageCodeAndIsVisible(langCode, true, params),
-        languages: Language.REAL_LANGUAGES, lang: langCode, totalMatches: 
totalMatches ]
+      [ corpusMatchList: matches,
+        languages: Language.REAL_LANGUAGES, lang: langCode, totalMatches: 
totalMatches,
+        matchesByRule: matchesByRule]
     }
 
     def markUseful = {

Modified: trunk/ltcommunity/grails-app/i18n/messages.properties
===================================================================
--- trunk/ltcommunity/grails-app/i18n/messages.properties       2011-11-18 
22:17:42 UTC (rev 5928)
+++ trunk/ltcommunity/grails-app/i18n/messages.properties       2011-11-18 
22:51:24 UTC (rev 5929)
@@ -44,6 +44,7 @@
 ltc.corpus.match.note=Note: we only check a very small subset of Wikipedia
 ltc.corpus.match.id=ID
 ltc.corpus.match.match=Match
+ltc.corpus.match.filter.submit=Filter
 
 ltc.registration.done.title=Registration Completed
 ltc.registration.done.text1=Thank you, your registration has been completed.

Modified: trunk/ltcommunity/grails-app/views/corpusMatch/list.gsp
===================================================================
--- trunk/ltcommunity/grails-app/views/corpusMatch/list.gsp     2011-11-18 
22:17:42 UTC (rev 5928)
+++ trunk/ltcommunity/grails-app/views/corpusMatch/list.gsp     2011-11-18 
22:51:24 UTC (rev 5929)
@@ -21,7 +21,23 @@
             <p><g:message code="ltc.corpus.match.note"/></p>
             
             <br />
-
+            
+            <form>
+                <input type="hidden" name="lang" 
value="${params.lang.encodeAsHTML()}"/>
+                <select name="filter">
+                    <option value="">- all rules -</option>
+                    <g:each in="${matchesByRule}" var="rule">
+                        <g:if test="${params.filter == rule[0]}">
+                            <option selected 
value="${rule[0].encodeAsHTML()}">${rule[0].encodeAsHTML()} 
(${rule[1].encodeAsHTML()} matches)</option>
+                        </g:if>
+                        <g:else>
+                            <option 
value="${rule[0].encodeAsHTML()}">${rule[0].encodeAsHTML()} 
(${rule[1].encodeAsHTML()} matches)</option>
+                        </g:else>
+                    </g:each>
+                </select>
+                <g:actionSubmit 
value="${message(code:'ltc.corpus.match.filter.submit')}" action="list"/>
+            </form>
+            
             <div class="list">
                 <table>
                     <thead>

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Languagetool-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-cvs

Reply via email to