• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Word类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.swabunga.spell.engine.Word的典型用法代码示例。如果您正苦于以下问题:Java Word类的具体用法?Java Word怎么用?Java Word使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Word类属于com.swabunga.spell.engine包,在下文中一共展示了Word类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getProposals

import com.swabunga.spell.engine.Word; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public ICompletionProposal[] getProposals(IQuickAssistInvocationContext context) {
    List<Word> sugg = fError.getSuggestions();
    int length = fError.getInvalidWord().length();
    ICompletionProposal[] props = new ICompletionProposal[sugg.size() + 2];
    for (int i=0; i < sugg.size(); i++) {
        String suggestion = sugg.get(i).toString();
        String s = MessageFormat.format(CHANGE_TO,
                new Object[] { suggestion });
        props[i] = new CompletionProposal(suggestion, 
                fOffset, length, suggestion.length(), fCorrectionImage, s, null, null);
    }
    props[props.length - 2] = new IgnoreProposal(ignore, fError.getInvalidWord(), context.getSourceViewer());
    props[props.length - 1] = new AddToDictProposal(fError, fLang, context.getSourceViewer());
    return props;
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:18,代码来源:TexSpellingEngine.java


示例2: checkWordSynchronous

import com.swabunga.spell.engine.Word; //导入依赖的package包/类
public boolean checkWordSynchronous(String word) {
    mMisspelledWords.clear();
    mSuggestions.clear();
    boolean misspelled = !(mDictionary.isCorrect(word));
    if (misspelled) {
        List suggestionsList = mDictionary.getSuggestions(word, 5); //max 3 suggestions
        ArrayList suggestionsForWord = new ArrayList<String>();
        for (Iterator suggestedWord = suggestionsList.iterator(); suggestedWord.hasNext(); ) {
            Word currentSuggestion = (Word) suggestedWord.next();
            suggestionsForWord.add(currentSuggestion.getWord());
        }
        mSuggestions.put(word, suggestionsForWord);
    }
    return misspelled;
    // returns true if word was misspelled
}
 
开发者ID:scheah,项目名称:eulexia,代码行数:17,代码来源:SpellCheck.java


示例3: spellingError

import com.swabunga.spell.engine.Word; //导入依赖的package包/类
public void spellingError(SpellCheckEvent event) {
    String invalidWord = event.getInvalidWord();
    List suggestionsList = event.getSuggestions();
    //System.out.println("Invalid Word: " + event.getInvalidWord());
    if (mSuggestions.containsKey(invalidWord)) // if we already recorded this misspell previously, exit
        return;
    mMisspelledWords.add(event.getInvalidWord());
    ArrayList suggestionsForWord = new ArrayList<String>();
    for (Iterator suggestedWord = suggestionsList.iterator(); suggestedWord.hasNext();) {
        Word currentSuggestion = (Word) suggestedWord.next();
        suggestionsForWord.add(currentSuggestion.getWord());
        //System.out.println("\tSuggested Word: " + currentSuggestion);
    }
    mSuggestions.put(invalidWord, suggestionsForWord);

}
 
开发者ID:scheah,项目名称:eulexia,代码行数:17,代码来源:SpellCheck.java


示例4: makeSuggestionsCapitalized

import com.swabunga.spell.engine.Word; //导入依赖的package包/类
/**
 *  Description of the Method
 *
 * @param  suggestions  Description of the Parameter
 * @return              Description of the Return Value
 */
private List makeSuggestionsCapitalized(List suggestions) {
	Iterator iterator = suggestions.iterator();
	while (iterator.hasNext()) {
		Word word = (Word) iterator.next();
		String suggestion = word.getWord();
		StringBuffer stringBuffer = new StringBuffer(suggestion);
		stringBuffer.setCharAt(0, Character.toUpperCase(suggestion.charAt(0)));
		word.setWord(stringBuffer.toString());
	}
	return suggestions;
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:18,代码来源:SpellChecker.java


示例5: getSuggestions

import com.swabunga.spell.engine.Word; //导入依赖的package包/类
public List<String> getSuggestions(String misspelledWord){

        @SuppressWarnings("unchecked")
        List<Word> suggestionsList = spellChecker.getSuggestions(misspelledWord, 0);
        List<String> suggestions = new ArrayList<String>();
        for (Word suggestion : suggestionsList){
            suggestions.add(suggestion.getWord());
        }

        return suggestions;
    }
 
开发者ID:ikhamlic,项目名称:esct-messenger-bot,代码行数:12,代码来源:JazzySpellChecker.java


示例6: spellingError

import com.swabunga.spell.engine.Word; //导入依赖的package包/类
public void spellingError(SpellCheckEvent event) {
    @SuppressWarnings("unchecked")
    List<Word> suggestions = (List<Word>) event.getSuggestions();
    if (suggestions.size() > 0) {
        Iterator<Word> suggestedWord = suggestions.iterator();
        if (suggestedWord.hasNext()) {
            String orig = event.getInvalidWord();
            String sugg = suggestedWord.next().getWord();
            if (_correctionType == SpellCorrectionType.Add)
                event.replaceWord(sugg + " ( " + orig + " ) ", false);
            else if (_correctionType == SpellCorrectionType.Replace)
                event.replaceWord(sugg, false);
        }
    }
}
 
开发者ID:jatecs,项目名称:jatecs,代码行数:16,代码来源:SpellCheck.java


示例7: findSuggestions

import com.swabunga.spell.engine.Word; //导入依赖的package包/类
protected List<String> findSuggestions(String word, String lang, int maxSuggestions) throws SpellCheckException {
    List<String> suggestionsList = new ArrayList<String>(maxSuggestions);
    SpellChecker checker = (SpellChecker) getChecker(lang);
    ListIterator<Word> suggestionsIt = checker.getSuggestions(word, maxSuggestions).listIterator();
    while (suggestionsIt.hasNext()) {
        suggestionsList.add(suggestionsIt.next().getWord());
    }
    return suggestionsList;
}
 
开发者ID:andreymoser,项目名称:jspellchecker,代码行数:10,代码来源:JazzySpellCheckerServlet.java


示例8: SpellCheckError

import com.swabunga.spell.engine.Word; //导入依赖的package包/类
public SpellCheckError(SpellCheckEvent event, SpellChecker spellChecker) {
  this.error = event.getInvalidWord();
  this.position = event.getWordContextPosition();

  // List<String> suggestions = event.getSuggestions();
  List<Word> suggestions = spellChecker.getSuggestions(error, 1);

  if (suggestions != null && suggestions.size() > 0) {
    String firstSuggestion = suggestions.get(0).getWord();
    if (!firstSuggestion.equals(this.error)) {
      this.suggestion = firstSuggestion;
    }
  }
}
 
开发者ID:rquinio,项目名称:l10n-maven-plugin,代码行数:15,代码来源:SpellCheckError.java


示例9: makeSuggestionsCapitalized

import com.swabunga.spell.engine.Word; //导入依赖的package包/类
private List makeSuggestionsCapitalized(List suggestions) {
  Iterator iterator = suggestions.iterator();
  while(iterator.hasNext()) {
    Word word = (Word)iterator.next();
    String suggestion = word.getWord();
    StringBuffer stringBuffer = new StringBuffer(suggestion);
    stringBuffer.setCharAt(0, Character.toUpperCase(suggestion.charAt(0)));
    word.setWord(stringBuffer.toString());
  }
  return suggestions;
}
 
开发者ID:magsilva,项目名称:jazzy,代码行数:12,代码来源:SpellChecker.java


示例10: correct

import com.swabunga.spell.engine.Word; //导入依赖的package包/类
public String correct(String text, MapInteger context) throws Exception {
	StringBuilder b = new StringBuilder();
	Span[] sp = opennlp.tokenize(text);
	int pos = 0;
	for (Span label : sp) {
		if (label.getStart() > pos)
			b.append(text.substring(pos, label.getStart()));
		pos = label.getEnd();
		String word = text.substring(label.getStart(), label.getEnd());
		if (dict.isCorrect(word) || word.trim().length() == 1) {
			b.append(word);
			continue;
		}
		boolean ok = true;
		for (int i = 0; i < word.length(); i++) {
			if (!Character.isLetter(word.charAt(i))) {
				ok = false;
				break;
			}
		}
		if (!ok) {
			b.append(word);
			continue;
		}
		@SuppressWarnings("unchecked")
		List<Word> aa = dict.getSuggestions(word, 1);
		String best = null;
		int score = 0;

		for (Word o : aa) {
			if (o.getCost() > 100)
				continue;
			String w = o.getWord();
			int s = context.get(w);
			if (best == null || s > score) {
				best = w;
				score = s;
			}
		}
		if (best != null)
			word = best;
		b.append(word);
	}
	return b.toString().replace("``", "'").replace("`", "'").replace("  ", " ").replace("  ", " ")
			.replace("..", ".").trim();
}
 
开发者ID:kouylekov,项目名称:edits,代码行数:47,代码来源:SpellChecker.java



注:本文中的com.swabunga.spell.engine.Word类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LibVlc类代码示例发布时间:2022-05-22
下一篇:
Java PixelUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap