本文整理汇总了Java中com.swabunga.spell.engine.SpellDictionary类的典型用法代码示例。如果您正苦于以下问题:Java SpellDictionary类的具体用法?Java SpellDictionary怎么用?Java SpellDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpellDictionary类属于com.swabunga.spell.engine包,在下文中一共展示了SpellDictionary类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getHierarchyDictionaries
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
/**
* Returns the dictionaries of the local hierarchy.
*
* @param locale
* @return
*/
private Collection<SpellDictionary> getHierarchyDictionaries(Locale locale) {
Collection<SpellDictionary> dictionaries = new ArrayList<SpellDictionary>();
Locale currentLocale = locale;
while (currentLocale != null) {
dictionaries.addAll(getDictionaries(currentLocale));
currentLocale = PropertiesFileUtils.getParentLocale(currentLocale);
}
// Add root dictionaries, if there is at least another locale dependent dictionary
if (dictionaries.size() > 0) {
dictionaries.addAll(getDictionaries(null));
}
return dictionaries;
}
开发者ID:rquinio,项目名称:l10n-maven-plugin,代码行数:22,代码来源:LocaleTreeSpellCheckerRepository.java
示例2: loadDictionary
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
public synchronized void loadDictionary(LangDict lang) throws IOException {
if (lang == null || lang.equals(language)) {
return;
}
InputStream in = null;
Reader read = null;
try {
try {
in = lang.openStream();
} catch (FileNotFoundException e) {
TabbyChat.getLogger().warn(e + " Falling back to English.");
lang = LangDict.ENGLISH;
in = lang.openStream();
}
read = new InputStreamReader(in);
SpellDictionary dictionary = new SpellDictionaryHashMap(read);
spellCheck = new SpellChecker(dictionary);
spellCheck.setUserDictionary(userDict);
spellCheck.addSpellCheckListener(errors::add);
this.language = lang;
} finally {
Closeables.closeQuietly(in);
Closeables.closeQuietly(read);
}
}
开发者ID:killjoy1221,项目名称:TabbyChat-2,代码行数:26,代码来源:Spellcheck.java
示例3: getSuggestions
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
/**
* Produces a list of suggested word after looking for suggestions in various
* dictionaries. The order of dictionary lookup is:
* <ul>
* <li>The default user dictionary or the one set through
* {@link SpellChecker#setUserDictionary}</li>
* <li>The dictionary specified at construction time, if any.</li>
* <li>Any dictionary in the order they were added through
* {@link SpellChecker#addDictionary}</li>
* </ul>
*
* @param word The word for which we want to gather suggestions
* @param threshold the cost value above which any suggestions are
* thrown away
* @return the list of words suggested
*/
public List getSuggestions(String word, int threshold) {
if (this.threshold != threshold && cache != null) {
this.threshold = threshold;
cache.clear();
}
ArrayList suggestions = null;
// saruta removed
//if (cache != null)
// suggestions = (ArrayList) cache.get(word);
if (suggestions == null) {
suggestions = new ArrayList(50);
for (Enumeration e = dictionaries.elements(); e.hasMoreElements(); ) {
SpellDictionary dictionary = (SpellDictionary) e.nextElement();
if (dictionary != userdictionary)
VectorUtility.addAll(suggestions, dictionary.getSuggestions(word, threshold), false);
}
if (cache != null && cache.size() < cacheSize)
cache.put(word, suggestions);
}
VectorUtility.addAll(suggestions, userdictionary.getSuggestions(word, threshold), false);
suggestions.trimToSize();
return suggestions;
}
开发者ID:SarutaSan72,项目名称:Yass,代码行数:48,代码来源:SpellChecker.java
示例4: JTextComponentSpellChecker
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
/**
*Constructor for the JTextComponentSpellChecker object
*
* @param dict Description of the Parameter
* @param userDict Description of the Parameter
* @param title Description of the Parameter
*/
public JTextComponentSpellChecker(SpellDictionary dict, SpellDictionary userDict, String title) {
spellCheck = new SpellChecker(dict);
mainDict = dict;
spellCheck.setCache();
if (userDict != null)
spellCheck.setUserDictionary(userDict);
spellCheck.addSpellCheckListener(this);
dialogTitle = title;
messages = ResourceBundle.getBundle("com.swabunga.spell.swing.messages", Locale.getDefault());
markHandler = new AutoSpellCheckHandler(spellCheck, messages);
}
开发者ID:SarutaSan72,项目名称:Yass,代码行数:19,代码来源:JTextComponentSpellChecker.java
示例5: addDictionary
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
public void addDictionary(Locale locale, SpellDictionary dictionary) {
Collection<SpellDictionary> dictionaries = spellDictionaries.get(locale);
if (dictionaries == null) {
dictionaries = new ArrayList<SpellDictionary>();
spellDictionaries.put(locale, dictionaries);
}
dictionaries.add(dictionary);
}
开发者ID:rquinio,项目名称:l10n-maven-plugin,代码行数:9,代码来源:LocaleTreeSpellCheckerRepository.java
示例6: getDictionaries
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
/**
*
* @param locale
* @return never null
*/
private Collection<SpellDictionary> getDictionaries(Locale locale) {
Collection<SpellDictionary> dictionaries = spellDictionaries.get(locale);
if (dictionaries == null) {
dictionaries = new ArrayList<SpellDictionary>();
}
return dictionaries;
}
开发者ID:rquinio,项目名称:l10n-maven-plugin,代码行数:13,代码来源:LocaleTreeSpellCheckerRepository.java
示例7: SpellCheckValidator
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
/**
* Initialize by loading dictionaries following {@link Locale} naming convention
*
* @param logger
* @param directory
* dictionaries location
*/
public SpellCheckValidator(L10nValidatorLogger logger, File directory) {
super(logger);
spellCheckerLocaleRepository = new LocaleTreeSpellCheckerRepository(logger);
if (directory != null) {
logger.getLogger().info("Looking for .dic files in: " + directory.getAbsolutePath());
File[] files = directory.listFiles((FilenameFilter) new SuffixFileFilter(".dic"));
if (files == null || files.length == 0) {
logger.getLogger().warn("No dictionary file under folder " + directory.getAbsolutePath() + ". Skipping spellcheck validation.");
} else {
// Load each dictionary, using file name to detect associated locale
for (File file : files) {
try {
String fileName = FilenameUtils.getBaseName(file.getName());
String localePart = null;
String[] parts = fileName.split("_", 2);
if (parts[0].length() == 2) {
localePart = fileName;
} else if (parts.length == 2) {
localePart = parts[1];
}
Locale locale = PropertiesFileUtils.getLocale(localePart);
logger.getLogger().info("Loading file <" + file.getName() + "> associated to locale <" + locale + ">");
SpellDictionary dictionary = new SpellDictionaryHashMap(file);
spellCheckerLocaleRepository.addDictionary(locale, dictionary);
} catch (IOException e) {
logger.getLogger().error(e);
}
}
}
} else {
logger.getLogger().warn("No dictionary folder provided, skipping spellcheck validation.");
}
}
开发者ID:rquinio,项目名称:l10n-maven-plugin,代码行数:45,代码来源:SpellCheckValidator.java
示例8: getSuggestions
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
/**
* Produces a list of suggested word after looking for suggestions in various
* dictionaries. The order of dictionary lookup is:
* <ul>
* <li>The default user dictionary or the one set through
* {@link SpellChecker#setUserDictionary}</li>
* <li>The dictionary specified at construction time, if any.</li>
* <li>Any dictionary in the order they were added through
* {@link SpellChecker#addDictionary}</li>
* </ul>
*
* @param word The word for which we want to gather suggestions
* @param threshold the cost value above which any suggestions are
* thrown away
* @return the list of words suggested
*/
public List getSuggestions(String word, int threshold) {
if (this.threshold != threshold && cache != null) {
this.threshold = threshold;
cache.clear();
}
ArrayList suggestions = null;
if (cache != null)
suggestions = (ArrayList) cache.get(word);
if (suggestions == null) {
suggestions = new ArrayList();
for (Enumeration e = dictionaries.elements(); e.hasMoreElements();) {
SpellDictionary dictionary = (SpellDictionary) e.nextElement();
if (dictionary != userdictionary)
VectorUtility.addAll(suggestions, dictionary.getSuggestions(word, threshold), false);
}
if (cache != null && cache.size() < cacheSize)
cache.put(word, suggestions);
}
VectorUtility.addAll(suggestions, userdictionary.getSuggestions(word, threshold), false);
suggestions.trimToSize();
return suggestions;
}
开发者ID:magsilva,项目名称:jazzy,代码行数:47,代码来源:SpellChecker.java
示例9: addDictionary
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
/**
* Accumulates a dictionary at the end of the dictionaries list used
* for looking up words. Adding a dictionary give the flexibility to
* assign the base language dictionary, then a more technical, then...
*
* @param dictionary the dictionary to add at the end of the dictionary list.
*/
public void addDictionary(SpellDictionary dictionary) {
if (dictionary == null) {
throw new IllegalArgumentException("dictionary must be non-null");
}
this.dictionaries.addElement(dictionary);
}
开发者ID:SarutaSan72,项目名称:Yass,代码行数:14,代码来源:SpellChecker.java
示例10: isCorrect
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
/**
* Verifies if the word to analyze is contained in dictionaries. The order
* of dictionary lookup is:
* <ul>
* <li>The default user dictionary or the one set through
* {@link SpellChecker#setUserDictionary}</li>
* <li>The dictionary specified at construction time, if any.</li>
* <li>Any dictionary in the order they were added through
* {@link SpellChecker#addDictionary}</li>
* </ul>
*
* @param word The word to verify that it's spelling is known.
* @return true if the word is in a dictionary.
*/
public boolean isCorrect(String word) {
if (userdictionary.isCorrect(word))
return true;
for (Enumeration e = dictionaries.elements(); e.hasMoreElements(); ) {
SpellDictionary dictionary = (SpellDictionary) e.nextElement();
if (dictionary.isCorrect(word))
return true;
}
return false;
}
开发者ID:SarutaSan72,项目名称:Yass,代码行数:25,代码来源:SpellChecker.java
示例11: addDictionary
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
/**
* Accumulates a dictionary at the end of the dictionaries list used
* for looking up words. Adding a dictionary give the flexibility to
* assign the base language dictionary, then a more technical, then...
*
* @param dictionary the dictionary to add at the end of the dictionary list.
*/
public void addDictionary(SpellDictionary dictionary) {
if (dictionary == null) {
throw new IllegalArgumentException("dictionary must be non-null");
}
this.dictionaries.addElement(dictionary);
}
开发者ID:magsilva,项目名称:jazzy,代码行数:14,代码来源:SpellChecker.java
示例12: isCorrect
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
/**
* Verifies if the word to analyze is contained in dictionaries. The order
* of dictionary lookup is:
* <ul>
* <li>The default user dictionary or the one set through
* {@link SpellChecker#setUserDictionary}</li>
* <li>The dictionary specified at construction time, if any.</li>
* <li>Any dictionary in the order they were added through
* {@link SpellChecker#addDictionary}</li>
* </ul>
*
* @param word The word to verify that it's spelling is known.
* @return true if the word is in a dictionary.
*/
public boolean isCorrect(String word) {
if (userdictionary.isCorrect(word)) return true;
for (Enumeration e = dictionaries.elements(); e.hasMoreElements();) {
SpellDictionary dictionary = (SpellDictionary) e.nextElement();
if (dictionary.isCorrect(word)) return true;
}
return false;
}
开发者ID:magsilva,项目名称:jazzy,代码行数:23,代码来源:SpellChecker.java
示例13: SpellChecker
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
/**
* Constructs the SpellChecker. The default threshold is used
*
* @param dictionary The dictionary used for looking up words.
*/
public SpellChecker(SpellDictionary dictionary) {
this();
addDictionary(dictionary);
}
开发者ID:SarutaSan72,项目名称:Yass,代码行数:10,代码来源:SpellChecker.java
示例14: setUserDictionary
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
/**
* Registers the user dictionary to which words are added.
*
* @param dictionary the dictionary to use when the user specify a new word
* to add.
*/
public void setUserDictionary(SpellDictionary dictionary) {
userdictionary = dictionary;
}
开发者ID:SarutaSan72,项目名称:Yass,代码行数:10,代码来源:SpellChecker.java
示例15: setUserDictionary
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
/**
* Set user dictionary (used when a word is added)
*
* @param dictionary The new userDictionary value
*/
public void setUserDictionary(SpellDictionary dictionary) {
if (spellCheck != null)
spellCheck.setUserDictionary(dictionary);
}
开发者ID:SarutaSan72,项目名称:Yass,代码行数:10,代码来源:JTextComponentSpellChecker.java
示例16: SpellChecker
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
/**
* Constructs the SpellChecker. The default threshold is used
*
* @param dictionary The dictionary used for looking up words.
*/
public SpellChecker(SpellDictionary dictionary) {
this();
addDictionary(dictionary);
}
开发者ID:magsilva,项目名称:jazzy,代码行数:10,代码来源:SpellChecker.java
示例17: setUserDictionary
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
/**
* Registers the user dictionary to which words are added.
*
* @param dictionary the dictionary to use when the user specify a new word
* to add.
*/
public void setUserDictionary(SpellDictionary dictionary) {
userdictionary = dictionary;
}
开发者ID:magsilva,项目名称:jazzy,代码行数:10,代码来源:SpellChecker.java
示例18: addDictionary
import com.swabunga.spell.engine.SpellDictionary; //导入依赖的package包/类
void addDictionary(Locale locale, SpellDictionary dictionary);
开发者ID:rquinio,项目名称:l10n-maven-plugin,代码行数:2,代码来源:LocaleSpellCheckerRepository.java
注:本文中的com.swabunga.spell.engine.SpellDictionary类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论