Re: multiple grammar files

2014-02-12 Thread Marcin MiƂkowski
W dniu 2014-02-12 05:21, Andriy Rysin pisze:
 I finally got to implement my old dream :) - split grammar.xml for
 Ukrainian: it got quite big to maintain easily and it can be logically
 split by categories.
 It was really easy by overriding the getRuleFileNames() from Language
 class but I see that nobody else is doing that so I wanted to check
 first if anybody sees anything wrong with this approach.

Yeah, this is trivially easy. Basically, the harder part of our idea of 
multiple rules is to enable loading them via the user interface.

IMHO, you should have a static ListString with these names and simply 
loop through it:

public static final ListString grammarRules =
 Arrays.asList(grammar-spelling.xml, grammar-grammar.xml, 
grammar-barbarism.xml);

The code will be a bit cleaner then.

Regards,
Marcin


 Thanks
 Andriy

 diff --git
 a/languagetool-language-modules/uk/src/main/java/org/languagetool/language/Ukrainian.java
 b/languagetool-language-modules/uk/src/main/java/org/languagetool/language/Ukrainian.java
 index bcb1492..599fa4c 100644
 ---
 a/languagetool-language-modules/uk/src/main/java/org/languagetool/language/Ukrainian.java
 +++
 b/languagetool-language-modules/uk/src/main/java/org/languagetool/language/Ukrainian.java
 @@ -22,7 +22,9 @@
   import java.util.List;
   import java.util.Locale;

 +import org.languagetool.JLanguageTool;
   import org.languagetool.Language;
 +import org.languagetool.databroker.ResourceDataBroker;
   import org.languagetool.rules.CommaWhitespaceRule;
   import org.languagetool.rules.Rule;
   import org.languagetool.rules.WhitespaceRule;
 @@ -141,5 +143,20 @@
   SimpleReplaceRule.class
   );
 }
 +
 +  @Override
 +public ListString getRuleFileNames() {
 +  ListString ruleFileNames = super.getRuleFileNames();
 +ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
 +String dirBase = dataBroker.getRulesDir() + / + getShortName() + /;
 +
 +ruleFileNames.add(dirBase + grammar-spelling.xml);
 +ruleFileNames.add(dirBase + grammar-grammar.xml);
 +ruleFileNames.add(dirBase + grammar-barbarism.xml);
 +ruleFileNames.add(dirBase + grammar-style.xml);
 +ruleFileNames.add(dirBase + grammar-punctuation.xml);
 +
 +return ruleFileNames;
 +}

   }

 --
 Android apps run on BlackBerry 10
 Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
 Now with support for Jelly Bean, Bluetooth, Mapview and more.
 Get your Android app in front of a whole new audience.  Start now.
 http://pubads.g.doubleclick.net/gampad/clk?id=124407151iu=/4140/ostg.clktrk
 ___
 Languagetool-devel mailing list
 Languagetool-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/languagetool-devel




--
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151iu=/4140/ostg.clktrk
___
Languagetool-devel mailing list
Languagetool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/languagetool-devel


Re: multiple grammar files

2014-02-12 Thread Daniel Naber
On 2014-02-12 05:21, Andriy Rysin wrote:

 It was really easy by overriding the getRuleFileNames() from Language
 class but I see that nobody else is doing that so I wanted to check
 first if anybody sees anything wrong with this approach.

I don't see anything wrong, but we might rely on grammar.xml as the 
only file in some places. So it would be good if you could search the 
source (including languagetool-community-website) to see if there are 
such places that need fixing.

Regards
  Daniel


--
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151iu=/4140/ostg.clktrk
___
Languagetool-devel mailing list
Languagetool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/languagetool-devel


Re: multiple grammar files

2014-02-12 Thread Andriy Rysin
On 02/12/2014 12:14 PM, Daniel Naber wrote:
 On 2014-02-12 05:21, Andriy Rysin wrote:

 It was really easy by overriding the getRuleFileNames() from Language
 class but I see that nobody else is doing that so I wanted to check
 first if anybody sees anything wrong with this approach.
 I don't see anything wrong, but we might rely on grammar.xml as the 
 only file in some places. So it would be good if you could search the 
 source (including languagetool-community-website) to see if there are 
 such places that need fixing.

Quick search revealed less than a dozen references to grammar.xml in
java files (not counting comments and printouts). Some of them are in
tests and some of them are in langaugetool-standalone. It didn't look
like those would be a problem but I can't tell for sure as I don't use
standalone interface. This is probably what Marcin mentioned in his
email, but I am not sure if loading the rules via user interface is
something regular user would do...

Also community website referenced grammar.xml twice in message file,
but no direct references in the code (at least I could not find it).

Andriy

--
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151iu=/4140/ostg.clktrk
___
Languagetool-devel mailing list
Languagetool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/languagetool-devel


multiple grammar files

2014-02-11 Thread Andriy Rysin
I finally got to implement my old dream :) - split grammar.xml for
Ukrainian: it got quite big to maintain easily and it can be logically
split by categories.
It was really easy by overriding the getRuleFileNames() from Language
class but I see that nobody else is doing that so I wanted to check
first if anybody sees anything wrong with this approach.

Thanks
Andriy

diff --git
a/languagetool-language-modules/uk/src/main/java/org/languagetool/language/Ukrainian.java
b/languagetool-language-modules/uk/src/main/java/org/languagetool/language/Ukrainian.java
index bcb1492..599fa4c 100644
---
a/languagetool-language-modules/uk/src/main/java/org/languagetool/language/Ukrainian.java
+++
b/languagetool-language-modules/uk/src/main/java/org/languagetool/language/Ukrainian.java
@@ -22,7 +22,9 @@
 import java.util.List;
 import java.util.Locale;
 
+import org.languagetool.JLanguageTool;
 import org.languagetool.Language;
+import org.languagetool.databroker.ResourceDataBroker;
 import org.languagetool.rules.CommaWhitespaceRule;
 import org.languagetool.rules.Rule;
 import org.languagetool.rules.WhitespaceRule;
@@ -141,5 +143,20 @@
 SimpleReplaceRule.class
 );
   }
+ 
+  @Override
+public ListString getRuleFileNames() {
+  ListString ruleFileNames = super.getRuleFileNames();
+ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
+String dirBase = dataBroker.getRulesDir() + / + getShortName() + /;
+
+ruleFileNames.add(dirBase + grammar-spelling.xml);
+ruleFileNames.add(dirBase + grammar-grammar.xml);
+ruleFileNames.add(dirBase + grammar-barbarism.xml);
+ruleFileNames.add(dirBase + grammar-style.xml);
+ruleFileNames.add(dirBase + grammar-punctuation.xml);
+   
+return ruleFileNames;
+}
 
 }

--
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151iu=/4140/ostg.clktrk
___
Languagetool-devel mailing list
Languagetool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/languagetool-devel