当前位置: 首页>>代码示例>>Java>>正文


Java SpellDictionaryHashMap类代码示例

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


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

示例1: addDictionaries

import com.swabunga.spell.engine.SpellDictionaryHashMap; //导入依赖的package包/类
private void addDictionaries(SpellChecker checker, List<File> langDictionaries) throws SpellCheckException {
    for (File dicitonaryFile : langDictionaries) {
        Reader dictionaryReader = null;
        try {
            dictionaryReader = new BufferedReader(new InputStreamReader(new FileInputStream(dicitonaryFile)));
            checker.addDictionary(new SpellDictionaryHashMap(dictionaryReader));
        } catch (Exception ex) {
            throw new SpellCheckException("Failed to open dictionary=" + dicitonaryFile.getName(), ex);
        } finally {
            if (dictionaryReader != null) {
                try {
                    dictionaryReader.close();
                } catch (IOException e) {
                    logger.warning("Failed to close dictionary file " + dicitonaryFile.getPath());
                }
            }
        }
    }
}
 
开发者ID:andreymoser,项目名称:jspellchecker,代码行数:20,代码来源:JazzySpellCheckerServlet.java

示例2: SpellCheck

import com.swabunga.spell.engine.SpellDictionaryHashMap; //导入依赖的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
    }
 
开发者ID:scheah,项目名称:eulexia,代码行数:23,代码来源:SpellCheck.java

示例3: loadDictionary

import com.swabunga.spell.engine.SpellDictionaryHashMap; //导入依赖的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

示例4: SpellChecker

import com.swabunga.spell.engine.SpellDictionaryHashMap; //导入依赖的package包/类
/**
 * Constructs the SpellChecker.
 */
public SpellChecker() {
	try {
		userdictionary = new SpellDictionaryHashMap();
	}
	catch (IOException e) {
		throw new RuntimeException("this exception should never happen because we are using null phonetic file");
	}
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:12,代码来源:SpellChecker.java

示例5: SpellCheckValidator

import com.swabunga.spell.engine.SpellDictionaryHashMap; //导入依赖的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

示例6: SpellChecker

import com.swabunga.spell.engine.SpellDictionaryHashMap; //导入依赖的package包/类
/**
 * Constructs the SpellChecker.
 */
public SpellChecker() {
  try {
    userdictionary = new SpellDictionaryHashMap();
  } catch (IOException e) {
    throw new RuntimeException("this exception should never happen because we are using null phonetic file");
  }
}
 
开发者ID:magsilva,项目名称:jazzy,代码行数:11,代码来源:SpellChecker.java

示例7: SpellChecker

import com.swabunga.spell.engine.SpellDictionaryHashMap; //导入依赖的package包/类
private SpellChecker(OpenNLP opennlp_) throws Exception {
	opennlp = opennlp_;
	InputStream im = this.getClass().getClassLoader().getResource("words.txt").openStream();
	dict = new SpellDictionaryHashMap(new InputStreamReader(im));
}
 
开发者ID:kouylekov,项目名称:edits,代码行数:6,代码来源:SpellChecker.java

示例8: JTextComponentSpellChecker

import com.swabunga.spell.engine.SpellDictionaryHashMap; //导入依赖的package包/类
/**
 *Constructor for the JTextComponentSpellChecker object
 *
 * @param  dictFile         Description of the Parameter
 * @param  title            Description of the Parameter
 * @exception  IOException  Description of the Exception
 */
public JTextComponentSpellChecker(String dictFile, String title)
	throws IOException {
	this(new SpellDictionaryHashMap(new File(dictFile)), null, title);
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:12,代码来源:JTextComponentSpellChecker.java


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