⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kwic.java

📁 KWIC系统 采用管道/过滤器风格实现
💻 JAVA
字号:
import java.io.FileInputStream;
import java.io.IOException;
import javax.swing.*;
import javax.swing.text.*;


public class KWIC
{
	private JTextArea text;

	 public KWIC (String fileName, String algorithm, JTextArea textA) throws IOException
	 {
		 text=textA;
	     execute(fileName, algorithm, text);
     }

    public void execute(String file, String filterType, JTextArea resultPanel) throws IOException
    {
    	if ( filterType.compareTo("a1")==0 )
    	{
    		try
    		{
    		  Pipe in_cs = new Pipe();   //创建3个Pipe 类的对象
      		  Pipe cs_al = new Pipe();
      		  Pipe al_ou = new Pipe();

      		  FileInputStream in = new FileInputStream(file);  //文件输入流的对象,建立与 "file" 的连接

        	  //创建4个过滤器对象
        	  Input input = new Input(in, in_cs);      //企图利用 "in" 将“file"中的数据写入管道 "in_cs"
        	  CircularShifter shifter = new CircularShifter(in_cs, cs_al);  //企图将“in_cs"中的数据写入管道 "cs_al"
        	  Alphabetizer alpha = new Alphabetizer(cs_al, al_ou);   //企图将“cs_al"中的数据写入管道 "al_ou"
        	  Output output = new Output(al_ou, resultPanel,filterType);   //企图将“al_ou"中的数据写入标准输出设备

        	  input.start(); // run it !      //开始运行线程
        	  shifter.start();
        	  alpha.start();
        	  output.start();
        	}catch(IOException exc)
        	{
        	  exc.printStackTrace();
        	}
		}
		else if ( filterType.compareTo("a3")==0 )
		{
			try
    		{
    		  Pipe in_sl = new Pipe();   //创建3个Pipe 类的对象
      		  Pipe sl_ou = new Pipe();

      		  FileInputStream in = new FileInputStream(file);  //文件输入流的对象,建立与 "file" 的连接

        	  //创建4个过滤器对象
        	  Input input = new Input(in, in_sl);      //企图利用 "in" 将“file"中的数据写入管道 "in_cs"
        	  WordSorterByLength sortlen = new WordSorterByLength(in_sl, sl_ou);  //企图将“in_cs"中的数据写入管道 "cs_al"
        	  Output output = new Output(sl_ou, resultPanel,filterType);   //企图将“al_ou"中的数据写入标准输出设备

        	  input.start(); // run it !      //开始运行线程
        	  sortlen.start();
        	  output.start();
        	}catch(IOException exc)
        	{
        	  exc.printStackTrace();
        	}
		}
		else if ( filterType.compareTo("a2")==0 )
		{
            try
    		{
    		  Pipe in_ws = new Pipe();   //创建3个Pipe 类的对象
      		  Pipe ws_ou = new Pipe();

      		  FileInputStream in = new FileInputStream(file);  //文件输入流的对象,建立与 "file" 的连接

        	  //创建4个过滤器对象
        	  Input input = new Input(in, in_ws);      //企图利用 "in" 将“file"中的数据写入管道 "in_cs"
        	  SorterByWord sortword = new SorterByWord(in_ws, ws_ou);  //企图将“in_cs"中的数据写入管道 "cs_al"
        	  Output output = new Output(ws_ou, resultPanel,filterType);   //企图将“al_ou"中的数据写入标准输出设备

        	  input.start(); // run it !      //开始运行线程
        	  sortword.start();
        	  output.start();
        	}catch(IOException exc)
        	{
        	  exc.printStackTrace();
        	}
		}
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -