Knowledgebase Home Page  >  RapidSpell Web Java
Search the Knowledge Base
How can I ignore Japanese parts of English + Japanese mixed text?
https://keyoti.com/kb/Default.aspx?ToDo=view&questId=174&catId=45

Options

Print this page
Email this to a friend

To customize the spell checker to ignore certain parts of the text, or certain words, the RapidSpellChecker class can be subclassed and methods overridden.  In this example we will ignore any text with Japanese characters in it.

Step 1; Create a subclass of RapidSpellChecker

package spell;

import com.keyoti.rapidSpell.AdvancedTextBoundary;
import com.keyoti.rapidSpell.BadWord;
import com.keyoti.rapidSpell.CheckerEngineAdapter;
import java.util.HashMap;

import java.util.Vector;


public class JapaneseIgnoreChecker extends com.keyoti.rapidSpell.RapidSpellChecker {

 public JapaneseIgnoreChecker (String key){
  super(key);
 }

 public boolean lookUpMainDictionary(String word){
  if(isJapaneseChar(word.charAt(0)))return true;//ignore Japanese words
  else return super.lookUpMainDictionary(word);
 }

 boolean isJapaneseChar( char c ){
  //determine if 'c' is Japanese, by assuming that any chars over 3000 are Japanese
  //http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml
  if( ((int)c) > 3000) return true;
  else return false;
 }
 

}

Step 2; Compile the class and add it to your application.  This class can be compiled with a command like

javac -classpath ..\lib\RapidSpellWeb.jar spell\JapaneseIgnoreChecker.java

[assuming that the current directory is "web-inf/classes" and the JapaneseIgnoreChecker.java file is in "web-inf/classes/spell" and the RapidSpellWeb.jar file is in web-inf/lib]

The class needs to be added to the class path, either by combining it with the application's existing WAR, or JAR file, or by adding it to the application's classpath (eg. typically "web-inf/classes".

 

Step 3; Use this class by modifying the RapidSpellCheckerPopUp.jsp page create and use the object

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="/WEB-INF/RapidSpellWeb.tld" prefix="RapidSpellWeb" %>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<title>Spell Check</title>
<body>
<Center>

<%

spell.JapaneseIgnoreChecker parser = new spell.JapaneseIgnoreChecker("544F645B6157635C655667665E5763355052503A353A3B383E3A403F40493F4A4C4A494");

%>

<RapidSpellWeb:rapidSpellWeb checkerEngine="<%= parser %>"/>

</center>
</body>
</html>

[Note the license key expires Feb 11th 2008 - new keys can be obtained from http://keyoti.com/products/evaluation-key-generator/default.aspx?SKU=RSWEBJAVA ]

 

 


Related Questions:

Attachments:

No attachments were found.