package scau108;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.io.*;
class Interface extends JFrame{
private JButton jbuttonA,jbuttonB,jbuttonC,jbuttonD;
private TextArea textarea;
private JPanel jpanelA,jpanelB;
private String[] ArrayDictionary;
private int ArrayDictionaryLength;
private String[] ArrayText;
private int ArrayTextLength;
private HashSet hash;
private JFrame frame=this;
public Interface() {
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
}
});
setTitle("查错");
CreatJPanel();
CreatJButton();
CreatTextArea();
Add();
pack();
}
private void CreatJPanel(){
jpanelA=(JPanel)this.getContentPane();
jpanelB=new JPanel();
jpanelA.setLayout(new BorderLayout());
jpanelB.setLayout(new FlowLayout());
}
private void CreatJButton(){
CreatJButtonA();
CreatJButtonB();
CreatJButtonC();
}
private void CreatJButtonA(){
jbuttonA=new JButton("读取文件");
jbuttonA.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
Read text=new Read(frame,"C:\\text.txt");
ArrayText=text.getArray();
ArrayTextLength=text.getArrayLength();
textarea.setText("File Read Success!");
// text.Display(textarea);
}
});
}
private void CreatJButtonB(){
jbuttonB=new JButton("读取字典");
jbuttonB.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
Read dictionary=new Read(frame,"C:\\1.txt");
ArrayDictionary=dictionary.getArray();
ArrayDictionaryLength=dictionary.getArrayLength();
textarea.setText("");
hash=dictionary.getHashSetDircty();
textarea.setText("Dictionary Read Success!");
// dictionary.Display(textarea);
}
});
}
private void CreatJButtonC(){
jbuttonC=new JButton("进行匹配");
jbuttonC.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
WordAnalyse WA=new WordAnalyse(hash);
WA.check("e:\\CheckResult.txt",ArrayText,ArrayTextLength,textarea);
}
});
}
private void CreatTextArea()
{ textarea=new TextArea(" ",10,1,TextArea.SCROLLBARS_BOTH);
}
private void Add()
{ jpanelB.add(jbuttonA);
jpanelB.add(jbuttonB);
jpanelB.add(jbuttonC);
jpanelA.add(jpanelB,BorderLayout.NORTH);
jpanelA.add(textarea,BorderLayout.CENTER);
}
/* public void check(String path)
{ WordAnalyse WA=new WordAnalyse(hash);
int j,n;
long kk=System.currentTimeMillis();
int LineNum=0;
try{ FileWriter file=new FileWriter(path);
String Word[]=new String[100];
StringTokenizer st;
kk=System.currentTimeMillis();
for (int i=0;i<ArrayTextLength;i++)
{ j=0;
st=new StringTokenizer (ArrayText[i]," 123456789!,.<>=+-/?;'~!@#$%^&[]{}()*\n");
while (st.hasMoreTokens())
{ Word[j]=st.nextToken();
j++;
}
n=j;
file.write(WA.Analyse(Word,n,i));
LineNum=LineNum+WA.getErrorNumber();
}
file.write("The Error Word Number is "+LineNum+" !用时 "+(System.currentTimeMillis()-kk)+" 毫秒");
file.close();
}
catch (IOException ee) {;}
textarea.setText("Check Success! ");
}
*/
public static void main(String args[])
{
System.out.println("Starting Interface...");
Interface mainFrame=new Interface();
mainFrame.setVisible(true);
}
}
class WordAnalyse
{ public int ErrorNum=0;
public HashSet hash;
public WordAnalyse(HashSet Hash)
{ this.hash=Hash;
}
public String Analyse(String[] word,int Length,int line)
{ String error=new String();
ErrorNum=0;
for(int i=0;i<Length;i++)
{ if(!hash.contains(word[i]))
{ error=error+"Line "+line+"\t"+word[i]+"\n";
ErrorNum++;
}
}
return(error);
}
public void check(String path,String[] ArrayText,int ArrayTextLength,TextArea textarea)
{ // WordAnalyse WA=new WordAnalyse(hash);
int j,n;
long kk=System.currentTimeMillis();
int LineNum=0;
try{ FileWriter file=new FileWriter(path);
String Word[]=new String[100];
StringTokenizer st;
kk=System.currentTimeMillis();
for (int i=0;i<ArrayTextLength;i++)
{ j=0;
st=new StringTokenizer (ArrayText[i]," 123456789!,.<>=+-/?;'~!@#$%^&[]{}()*\n");
while (st.hasMoreTokens())
{ Word[j]=st.nextToken();
j++;
}
n=j;
file.write(Analyse(Word,n,i));
LineNum=LineNum+getErrorNumber();
}
file.write("The Error Word Number is "+LineNum+" !用时 "+(System.currentTimeMillis()-kk)+" 毫秒");
file.close();
}
catch (IOException ee) {;}
textarea.setText("Check Success! ");
}
public int getErrorNumber()
{return(ErrorNum);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
这是一个Java的拼写检查程序
共14个文件
class:9个
java:4个
txt:1个
需积分: 43 20 下载量 28 浏览量
2011-04-02
20:52:45
上传
评论 1
收藏 15KB RAR 举报
温馨提示
这是一个中文快速拼写检查的程序,编程语言为java,初学者很有参考价值。
资源推荐
资源详情
资源评论
收起资源包目录
快速拼写检查程序.rar (14个子文件)
JAVA5快速拼写检查程序
scau108
Interface.class 4KB
Interface$4.class 955B
Interface$1.class 552B
Interface$2.class 1KB
Read$1.class 542B
Read.class 4KB
Read$2.class 542B
WordAnalyse.class 2KB
Interface$3.class 1KB
InterfaceChengHash2.java 5KB
InterfaceChengHash3.java 4KB
InterfaceChengHash1.java 5KB
Read.java 2KB
www.pudn.com.txt 218B
共 14 条
- 1
资源评论
cpeng13
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功