Revision: 9388
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=9388&view=rev
Author:   dnaber
Date:     2013-02-16 15:21:37 +0000 (Sat, 16 Feb 2013)
Log Message:
-----------
introduce a main class that can be used to call all the other commands

Modified Paths:
--------------
    trunk/languagetool/languagetool-wikipedia/pom.xml
    
trunk/languagetool/languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/WikipediaQuickCheck.java

Added Paths:
-----------
    
trunk/languagetool/languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/Main.java

Modified: trunk/languagetool/languagetool-wikipedia/pom.xml
===================================================================
--- trunk/languagetool/languagetool-wikipedia/pom.xml   2013-02-16 15:05:34 UTC 
(rev 9387)
+++ trunk/languagetool/languagetool-wikipedia/pom.xml   2013-02-16 15:21:37 UTC 
(rev 9388)
@@ -44,7 +44,7 @@
               <configuration>
                 <archive>
                   <manifest>
-                    <mainClass>org.languagetool.dev.index.Indexer</mainClass>
+                    <mainClass>org.languagetool.dev.wikipedia.Main</mainClass>
                   </manifest>
                 </archive>
                 <descriptorRefs>

Added: 
trunk/languagetool/languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/Main.java
===================================================================
--- 
trunk/languagetool/languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/Main.java
                            (rev 0)
+++ 
trunk/languagetool/languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/Main.java
    2013-02-16 15:21:37 UTC (rev 9388)
@@ -0,0 +1,69 @@
+/* LanguageTool, a natural language style checker 
+ * Copyright (C) 2013 Daniel Naber (http://www.danielnaber.de)
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
+ * USA
+ */
+package org.languagetool.dev.wikipedia;
+
+import org.languagetool.dev.index.Indexer;
+import org.languagetool.dev.index.Searcher;
+
+import java.util.Arrays;
+
+/**
+ * A class to be called from command line - dispatches to the actual 
implementations
+ * by calling their main method.
+ */
+public class Main {
+
+  public static void main(String[] args) throws Exception {
+    if (args.length == 0) {
+      printUsageAndExit();
+    } else {
+      final String[] remainingArgs = Arrays.copyOfRange(args, 1, args.length);
+      final String command = args[0];
+      if (command.equals("check-dump")) {
+        CheckWikipediaDump.main(remainingArgs);
+      } else if (command.equals("wiki-index")) {
+        WikipediaIndexHandler.main(remainingArgs);
+      } else if (command.equals("wiki-check")) {
+        WikipediaQuickCheck.main(remainingArgs);
+      } else if (command.equals("index")) {
+        Indexer.main(remainingArgs);
+      } else if (command.equals("search")) {
+        Searcher.main(remainingArgs);
+      } else {
+        System.out.println("Error: unknown command '" + command + "'");
+        printUsageAndExit();
+      }
+    }
+  }
+
+  private static void printUsageAndExit() {
+    System.out.println("Usage: " + Main.class.getName() + " <command> 
<command-specific-argument>");
+    System.out.println("Where command is one of:");
+    System.out.println("   check-dump - check a Wikipedia XML dump");
+    System.out.println("   wiki-index - index a Wikipedia XML dump");
+    System.out.println("   wiki-check - check a single Wikipedia page, fetched 
via the Mediawiki API");
+    System.out.println("   index      - index a plain text file, putting the 
analysis in a Lucene index for faster rule match search");
+    System.out.println("   search     - search for rule matches in an index 
created with 'index' or 'wiki-index'");
+    System.out.println("All commands have different usages. Call them without 
arguments to get help.");
+    System.out.println("Example:");
+    System.out.println("   java -jar languagetool-wikipedia.jar wiki-check 
http://de.wikipedia.org/wiki/Bielefeld";);
+    System.exit(1);
+  }
+
+}

Modified: 
trunk/languagetool/languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/WikipediaQuickCheck.java
===================================================================
--- 
trunk/languagetool/languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/WikipediaQuickCheck.java
     2013-02-16 15:05:34 UTC (rev 9387)
+++ 
trunk/languagetool/languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/WikipediaQuickCheck.java
     2013-02-16 15:21:37 UTC (rev 9388)
@@ -157,17 +157,17 @@
   }*/
     
   public static void main(String[] args) throws IOException {
+    if (args.length != 1) {
+      System.out.println("Usage: " + WikipediaQuickCheck.class.getName() + " 
<url>");
+      System.exit(1);
+    }
     final WikipediaQuickCheck check = new WikipediaQuickCheck();
-    //final String urlString = "http://de.wikipedia.org/wiki/Hof";;
-    //final String urlString = "http://de.wikipedia.org/wiki/Gütersloh";;
-    //final String urlString = "http://de.wikipedia.org/wiki/Bielefeld";;
-    //final String urlString = "http://de.wikipedia.org/wiki/Berlin";;
-    //final String urlString = "http://de.wikipedia.org/wiki/Köln";;
+    // URL examples:
     //final String urlString = "http://de.wikipedia.org/wiki/Angela_Merkel";;
-    //final String urlString = "http://de.wikipedia.org/wiki/Wortschatz";;
     //final String urlString = 
"https://de.wikipedia.org/wiki/Benutzer_Diskussion:Dnaber";;
     //final String urlString = 
"https://secure.wikimedia.org/wikipedia/de/wiki/G%C3%BCtersloh";;
-    final String urlString = 
"https://secure.wikimedia.org/wikipedia/de/wiki/Benutzer_Diskussion:Dnaber";;
+    //final String urlString = 
"https://secure.wikimedia.org/wikipedia/de/wiki/Benutzer_Diskussion:Dnaber";;
+    final String urlString = args[0];
     final URL url = new URL(urlString);
     final String mediaWikiContent = check.getMediaWikiContent(url);
     final String plainText = check.getPlainText(mediaWikiContent);

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


------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, 
is your hub for all things parallel software development, from weekly thought 
leadership blogs to news, videos, case studies, tutorials, tech docs, 
whitepapers, evaluation guides, and opinion stories. Check out the most 
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits

Reply via email to