Comment créer un dictionnaire pour la vérification orthographique avec Language Tool? Je ne suis pas un programmeur Java et c'était la première fois que je voyais LT.Dans LanguageTool, comment créer un dictionnaire et l'utiliser pour la vérification orthographique?
Dans LanguageTool, comment créer un dictionnaire et l'utiliser pour la vérification orthographique?
Répondre
Bonjour, c'est mon expérience dans la création d'un dictionnaire pour la correction orthographique avec Language Tool! Je espère que vous l'apprécierez.
Partie 1: Comment créer le dictionnaire
Vous devez:
• Un fichier .txt avec le dictionnaire intérieur
• Un fichier spécifiant les informations .info sur la façon de définir Fichier de sortie LT (Il est déjà présent dans le répertoire LT).
• version autonome LanguageTool
• Java 8
A la fin de cette section, vous aurez:
• un fichier .dict-à-dire le fichier avec votre dictionnaire sous une forme lisible pour LT
- Installez la version DERNIERE de LT: https://languagetool.org/download/snapshots/?C=M;O=D
- Assurez-vous de VHA e votre fichier .txt dans le bon format (a) et l'encodage (b): a. 1 mot par ligne b. Codage UTF8
- Dans la ligne de commande, écrivez: a. java -cp chemin languagetool.jar org.languagetool.tools.SpellDictionaryBuilder -i en_US chemin du fichier dictionnaire -info du fichier .info chemin -o du fichier de sortie
où:
i. fr_FR est le code relatif à la langue du dictionnaire
ii. -i c'est le paramètre du fichier d'entrée (votre fichier .txt)
iii. -info c'est le paramètre du fichier .info lié au dictionnaire. Vous pouvez le créer en suivant ces instructions (http://wiki.languagetool.org/hunspell-support - section "Configuration du dictionnaire") ou utiliser le fichier .info déjà présent - si présent - dans \ org \ languagetool \ resource \ yourlanguage
iv. -o c'est le paramètre pour specifing où vous souhaitez enregistrer le fichier de sortie .dict
Partie 2: Comment intégrer le dictionnaire LT pour vérification orthographique
Vous avez besoin:
• JDK 1.8 (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
• Maven (https://maven.apache.org/download.cgi)
• IDE pour Java (JetBrains, Eclipse, etc.)
• fichier + fichier .info de .dict (voir part1)
• projet GitHub LanguageTool (https://github.com/languagetool-org/languagetool)
- Définir le chemin bin JDK et Maven (plus d'info: https://maven.apache.org/install.html)
- Copiez les fichiers .info et .dict créés sur la partie 1 dans \ languagetool-master \ languagetool-language-modules \ YourLanguage \ src \ main \ resources \ org \ langagetool \ resource \ YourLanguage \ hunspell
- Ouvrez avec votre IDE le Fichier java appelé comme langue de votre dictionnaire (par ex. French.java):
a. Changer HunspellNoSuggestionRule en YourLanguage.java à MorfologikYourLanguageSpellerRule
@Override
public List<Rule> getRelevantRules(ResourceBundle messages) throws IOException {
return Arrays.asList(
new CommaWhitespaceRule(messages),
new DoublePunctuationRule(messages),
new GenericUnpairedBracketsRule(messages,
Arrays.asList("[", "(", "{" /*"«", "‘"*/),
Arrays.asList("]", ")", "}"
/*"»", French dialog can contain multiple sentences. */
/*"’" used in "d’arm" and many other words */)),
new MorfologikYourLanguageSpellerRule(messages, this),
new UppercaseSentenceStartRule(messages, this),
new MultipleWhitespaceRule(messages, this),
new SentenceWhitespaceRule(messages),
// specific to French:
new CompoundRule(messages),
new QuestionWhitespaceRule(messages)
);
}
b. Créer le nouveau MorfologikYourLanguageSpellerRule.java dans \ LanguageTool maître \ LanguageTool-langue-modules \ Yourlanguage \ src \ main \ java \ org \ LanguageTool \ règles \ Yourlanguage:
/* LanguageTool, a natural language style checker
* Copyright (C) 2012 Marcin Miłkowski (http://www.languagetool.org)
*
* 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.rules.fr;
import java.io.IOException;
import java.util.ResourceBundle;
import org.languagetool.Language;
import org.languagetool.rules.spelling.morfologik.MorfologikSpellerRule;
public final class MorfologikYourLanguageSpellerRule extends MorfologikSpellerRule {
public static final String RULE_ID = "MORFOLOGIK_RULE_CODEOFYOURLANGUAGE"; /* for ex. Fr_FR for French */
private static final String RESOURCE_FILENAME = "PATH TO YOUR .DICT FILE";
public MorfologikFrenchSpellerRule(ResourceBundle messages,
Language language) throws IOException {
super(messages, language);
}
@Override
public String getFileName() {
return RESOURCE_FILENAME;
}
@Override
public String getId() {
return RULE_ID;
}
}
c. Allez dans \ languagetool-master \ avec votre ligne de commande et écrivez: Mvn package
d. Voir vos résultats dans \ languagetool-master \ languagetool-autonome \ target \ LanguageTool-3.4-SNAPSHOT \ LanguageTool-3.4-SNAPSHOT.