@Override public void setLanguages (LocaleId sourceLocale, LocaleId targetLocale) { super.setLanguages(sourceLocale, targetLocale); // Convert the codes srcJavaLoc = sourceLocale.toJavaLocale(); trgJavaLoc = targetLocale.toJavaLocale(); // Try to set the direction setDirectionId(); }
public WordCounter (LocaleId locId) { breaker = BreakIterator.getWordInstance(locId.toJavaLocale()); } public long getWordCount (String text) {
/** * Create a {@link AlphabeticNgramTokenizer} * * @param ngramSize * size of ngram in characters * @param localeId * {@link LocaleId} of the content being tokenized * @return a {@link AlphabeticNgramTokenizer} */ public static AlphabeticNgramTokenizer createNgramTokenizer(int ngramSize, LocaleId localeId) { return new AlphabeticNgramTokenizer(new StringReader(""), ngramSize, localeId .toJavaLocale()); } }
public WordCounter (LocaleId locId) { breaker = BreakIterator.getWordInstance(locId.toJavaLocale()); String lng = locId.getLanguage(); replaceApos = ( lng.equals("fr") || lng.equals("it") ); }
/** * Creates a new TextMatcher object. * @param locale1 locale of the first language. * @param locale2 locale of the second language. */ public TextMatcher (LocaleId locale1, LocaleId locale2) { // Create the first breaker. breaker1 = BreakIterator.getWordInstance(locale1.toJavaLocale()); if ( locale1.equals(locale2) ) { // Use the same one if the second language is the same. breaker2 = breaker1; } else { // If two different languages: create a second breaker. breaker2 = BreakIterator.getWordInstance(locale2.toJavaLocale()); } }
ResourceBundle.getBundle(baseName, locale.toJavaLocale(), control); return control.toString();
cmd = cmd.replace(Util.INPUT_ROOT_DIRECTORY_VAR, inputRootDir); Locale loc = rawDoc.getSourceLocale().toJavaLocale(); cmd = cmd.replace("${srcLangName}", loc.getDisplayLanguage(Locale.ENGLISH)); loc = rawDoc.getTargetLocale().toJavaLocale(); cmd = cmd.replace("${trgLangName}", loc.getDisplayLanguage(Locale.ENGLISH));
try { prop.load(new FileInputStream(propFile)); keyWithLoc = parsedKey + "." + targetLocale.toJavaLocale().getLanguage().toUpperCase(); String category = prop.getProperty(keyWithLoc); if ( category != null ) { while ( index != -1 ) { parsedKey = parsedKey.substring(0, index); keyWithLoc = parsedKey + "." + targetLocale.toJavaLocale().getLanguage().toUpperCase(); category = prop.getProperty(keyWithLoc); if ( category != null ) {
/** * Initializes this extractor. This must be called before starting to process the input files. * @param params the options to use. * @param sourceLocaleId the source locale. * @param rootDir the value to use for the ${rootDir} variable (can be null). * @param inputRootDir the value to use for the ${inputRootDir} variable (can be null). */ public void initialize (Parameters params, LocaleId sourceLocaleId, String rootDir, String inputRootDir) { this.srcLocale = sourceLocaleId.toJavaLocale(); this.params = params; this.rootDir = rootDir; this.inputRootDir = inputRootDir; stopWords = loadList(params.getStopWordsPath(), "stopWords_en.txt"); notStartWords = loadList(params.getNotStartWordsPath(), "notStartWords_en.txt"); notEndWords = loadList(params.getNotEndWordsPath(), "notEndWords_en.txt"); terms = new LinkedHashMap<String, Integer>(); termsFromAnnotations = new LinkedHashMap<String, Integer>(); breaker = null; }
@StepParameterMapping(parameterType = StepParameterType.SOURCE_LOCALE) public void setSourceLocale (LocaleId sourceLocale) { this.srcLoc = sourceLocale; srcWordIterator = (RuleBasedBreakIterator) BreakIterator.getWordInstance(ULocale .createCanonical(srcLoc.toString())); RuleBasedBreakIterator.registerInstance(srcWordIterator, srcLoc.toJavaLocale(), BreakIterator.KIND_WORD); }