我有一个使用RoWordNet(罗马尼亚的wordnet)的java程序。问题是每次运行程序都需要1分钟的时间来加载数据库。我想只在第一次执行时加载数据库,然后在每次执行时使用,而不需要再次加载。谢谢.代码。
import data.*;
import io.*;
import java.util.ArrayList;
public class main {
public static void main(final String[] args) throws Exception {
IO.outln("Loading RoWordNet ...");
// to read from XML :
// RoWordNet rown = new RoWordNet(XMLRead.read("res\\rown.xml"));
// to read from raw (serialized) object :
// this is the line with reading
RoWordNet rown = RoWordNet.deserializeFromFile("RoWordNet\\res\\RoWordNet.data");
Literal l1 = new Literal("magazin");
ArrayList<Synset> arr = rown.getSynsetsFromLiteral(l1);
int dim =arr.size();
ArrayList<String> justLiterals = new ArrayList<String>();
for(int i=0;i<dim;i++)
{
ArrayList<Literal> literalsWithSense = new ArrayList<Literal>();
literalsWithSense=(ArrayList<Literal>)arr.get(i).getLiterals();
int numOfLiterals=literalsWithSense.size();
for (int j=0;j<numOfLiterals;j++)
{
String literal=new String();
literal=literalsWithSense.get(j).getLiteral();
if (! justLiterals.contains(literal)){
justLiterals.add(literal);
}
}
}
System.out.println(justLiterals);
}
}