本文整理汇总了Java中com.swabunga.spell.event.SpellChecker.addSpellCheckListener方法的典型用法代码示例。如果您正苦于以下问题:Java SpellChecker.addSpellCheckListener方法的具体用法?Java SpellChecker.addSpellCheckListener怎么用?Java SpellChecker.addSpellCheckListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.swabunga.spell.event.SpellChecker
的用法示例。
在下文中一共展示了SpellChecker.addSpellCheckListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SpellCheck
import com.swabunga.spell.event.SpellChecker; //导入方法依赖的package包/类
protected SpellCheck(Context context/*, String bodyText*/) {
mContext = context;
//mOriginalText = bodyText;
AssetManager assetManager = context.getAssets();
try {
File directoryOnDisk = mContext.getFilesDir();
if (!directoryOnDisk.exists()) directoryOnDisk.mkdirs();
InputStream dictInputStream = assetManager.open(dictFile);
// Following code used for disk-based dictionary
// File dict = createFileFromInputStream(dictInputStream, dictFile);
// InputStream phoneticInputStream = assetManager.open(phoneticFile);
// File phonetic = createFileFromInputStream(phoneticInputStream, phoneticFile);
// mDictionary = new SpellDictionaryCachedDichoDisk(dict);
Reader reader = new InputStreamReader(dictInputStream, "UTF-8");
mDictionary = new SpellDictionaryHashMap(reader);
} catch (IOException e) {
e.printStackTrace();
}
jazzySpellCheck = new SpellChecker(mDictionary);
jazzySpellCheck.addSpellCheckListener(this); // callbacks implemented in this class, can possibly add listener to a different class
//jazzySpellCheck.checkSpelling(new StringWordTokenizer(bodyText)); // asynchronous
}
示例2: loadDictionary
import com.swabunga.spell.event.SpellChecker; //导入方法依赖的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);
}
}
示例3: JTextComponentSpellChecker
import com.swabunga.spell.event.SpellChecker; //导入方法依赖的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);
}
示例4: check
import com.swabunga.spell.event.SpellChecker; //导入方法依赖的package包/类
public void check(IDocument document, IRegion[] regions, SpellingContext context,
ISpellingProblemCollector collector, IProgressMonitor monitor) {
if (ignore == null) {
ignore = new HashSet<String>();
}
IProject project = getProject(document);
String lang = DEFAULT_LANG;
if (project != null) {
lang = TexlipseProperties.getProjectProperty(project, TexlipseProperties.LANGUAGE_PROPERTY);
}
//Get spellchecker for the correct language
SpellChecker spellCheck = getSpellChecker(lang);
if (spellCheck == null) return;
if (collector instanceof TeXSpellingProblemCollector) {
((TeXSpellingProblemCollector) collector).setRegions(regions);
}
try {
spellCheck.addSpellCheckListener(this);
for (final IRegion r : regions) {
errors = new LinkedList<SpellCheckEvent>();
int roffset = r.getOffset();
//Create a new wordfinder and initialize it
TexlipseWordFinder wf = new TexlipseWordFinder();
wf.setIgnoreComments(TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.SPELLCHECKER_IGNORE_COMMENTS));
wf.setIgnoreMath(TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.SPELLCHECKER_IGNORE_MATH));
spellCheck.checkSpelling(new StringWordTokenizer(
document.get(roffset, r.getLength()), wf));
for (SpellCheckEvent error : errors) {
SpellingProblem p = new TexSpellingProblem(error, roffset, lang);
collector.accept(p);
}
}
spellCheck.removeSpellCheckListener(this);
} catch (BadLocationException e) {
e.printStackTrace();
}
}
示例5: validate
import com.swabunga.spell.event.SpellChecker; //导入方法依赖的package包/类
/**
* WARN in case of spellcheck error using property locale.
*/
public int validate(Property property, List<L10nReportItem> reportItems) {
Locale locale = property.getLocale();
if (locale == null) {
// Case of root bundle
locale = Locale.ENGLISH;
}
SpellChecker spellChecker = spellCheckerLocaleRepository.getSpellChecker(locale);
if (spellChecker != null) {
ListSpellCheckErrorListener listener = new ListSpellCheckErrorListener(spellChecker);
spellChecker.addSpellCheckListener(listener);
String message = property.getMessage();
spellChecker.checkSpelling(new StringWordTokenizer(message));
Collection<SpellCheckError> errors = listener.getSpellCheckErrors();
// The message with errors replaced by suggestions
String correction = message;
// Start from last errors, so that error position remains valid
SpellCheckError[] errs = errors.toArray(new SpellCheckError[errors.size()]);
for (int i = errs.length - 1; i >= 0; i--) {
SpellCheckError error = errs[i];
if (error.getSuggestion() != null) {
int pos = error.getPosition();
correction = StringUtils.overlay(correction, error.getSuggestion(), pos, pos + error.getError().length());
}
}
if (errors.size() > 0) {
StringBuffer sb = new StringBuffer();
sb.append("Spellcheck error on word(s): ").append(errors.toString()).append(" and locale <").append(locale).append(">.");
if (correction != null) {
sb.append(" Suggested correction: [").append(correction).append("]");
}
L10nReportItem reportItem = new L10nReportItem(Type.SPELLCHECK, sb.toString(), property, null);
reportItems.add(reportItem);
logger.log(reportItem);
}
spellChecker.removeSpellCheckListener(listener);
}
return 0;
}
示例6: initialize
import com.swabunga.spell.event.SpellChecker; //导入方法依赖的package包/类
private void initialize(){
spellChecker = new SpellChecker(dictionaryHashMap);
spellChecker.addSpellCheckListener(this);
}