资源简介
这是一个英文分词工具里面有详细的介绍使用方法
代码片段和文件信息
/* AlnLoader.java
* ==============
* Mike Jahr 8/16/99
* Machine Translation group WS99
* Center for Language and Speech Processing
*/
import java.net.URL;
import java.io.*;
import javax.swing.SwingUtilities;
/**
* Thread class responsible for loading an alignment file.
* AlnLoader
knows the “.aln“ format and given the url of a
* file can load it into a given translation object. It reports any
* errors it encounters via the {@link Cairo#ReportError(String)
* Cairo.ReportError} method.
* @author Mike Jahr
* @see Cairo
* @see Translation
*/
public class AlnLoader extends Thread {
// public static String FILE_SUFFIX = “.aln“;
private Cairo c;
private Translation trans;
private URL url;
/**
* Creates a loader with the given specifications.
* @see Cairo#openURL(URL)
*/
public AlnLoader(Cairo inc Translation intrans URL inurl) {
super();
c = inc;
trans = intrans;
url = inurl;
}
/**
* Attempts to open an alignment file specified by the URL in the
* constructor into the translation object.
*/
public void run() {
//DBG*/c.ReportError(“started run“);
// if there‘s already a load thread running we must wait for it.
try {
Thread t = c.getLoadThread();
if (t != null && t.isAlive()) {
t.interrupt();
t.join();
}
} catch (InterruptedException ie) {
return;
}
c.setLoadThread(this);
StreamTokenizer st = null;
try {
st = makeTokenizer(null);
} catch (IOException ioe) {
c.ReportError(“I/O error with alignment file: “ + ioe.getMessage());
c.setLoadThread(null);
return;
}
//DBG*/c.ReportError(“made tokenizer“);
try {
int curtag = -1;
trans.clear();
while (!isInterrupted()) {
try {
curtag = nextTag(st curtag);
//DBG*/System.err.println(“got tag “ + curtag + “:“ + openTag(curtag));
if (st.ttype == st.TT_EOF)
break;
switch (curtag) {
case HEADER:
if (trans.encoding == null) {
//boolean first = (trans.encoding == null);
trans.readHeader(st);
if (trans.encoding != null)
st = makeTokenizer(trans.encoding);
}
break; // ““
case SOURCE_SENTENCE:
trans.source.readWords(st);
break; // ““
case TARGET_SENTENCE:
trans.target.readWords(st);
break; // ““;
case ALIGNMENT:
trans.web.readAlignment(st);
break; // ““;
case ASCII:
break; // ““;
case PROBABILITY:
trans.target.readProb(st);
break; // ““;
case NULL_FERTILITY:
trans.NULL_WORD.readProb(st);
break; // ““;
case FERTILITIES:
trans.target.readFertility(st true);
break; // ““;
case ALT_FERTILITIES:
trans.target.readFertility(st false);
break; // ““;
case DISTORTI
- 上一篇:电路演示小软件
- 下一篇:机关公文助手完全破解版
评论
共有 条评论