📄 sentencebase.java
字号:
package dragon.nlp.tool.xtract;import dragon.matrix.*;import dragon.nlp.*;/** * <p>Sentence base class provides functions of adding and saving sententce to matrix</p> * <p> </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: IST, Drexel University</p> * @author Davis Zhou * @version 1.0 */public class SentenceBase { private SparseMatrixFactory factory; private IntFlatSparseMatrix cacheMatrix; private String indexFile; private int sentenceNum, threshold; public SentenceBase(String indexFile, String matrixFile) { this.indexFile =indexFile; factory=new SparseMatrixFactory(matrixFile,4); cacheMatrix=new IntFlatSparseMatrix(); sentenceNum=factory.rows(); threshold=500000; } public int addSentence(Sentence sent){ Word cur; int sentIndex; sentIndex=sentenceNum; sentenceNum++; cur=sent.getFirstWord(); while(cur!=null){ cacheMatrix.add(sentIndex,cur.getIndex(),cur.getPOSIndex()); cur=cur.next; } if(cacheMatrix.getNonZeroNum()>=threshold) { cacheMatrix.finalizeData(false); factory.add(cacheMatrix); cacheMatrix.close(); } return sentIndex; } public void close(){ cacheMatrix.finalizeData(false); factory.add(cacheMatrix); cacheMatrix.close(); factory.genIndexFile(indexFile); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -