/**
* @param args
*/
public static void main(String[] args) throws Exception {
ResultDbReader rdbr = ResultDbReader.getInstance();
Map<Integer,String> paperIdToPath = new HashMap<Integer, String>();
Map<String,Document> pathToSaf = new HashMap<String, Document>();
Map<String,Document> pathToNewSaf = new HashMap<String, Document>();
for(int i=0;i<30000;i++) {
Document rmrsDoc = rdbr.getRmrs(i);
if(!rmrsDoc.getRootElement().getLocalName().equals("error")) {
Serializer ser;
ser = new Serializer(System.out);
//ser.setIndent(2);
ser.write(rmrsDoc);
int sentenceId = Integer.parseInt(rmrsDoc.getRootElement().getAttributeValue("sentenceid"));
Document sentDoc = rdbr.getSentence(sentenceId);
ser = new Serializer(System.out);
ser.setIndent(2);
ser.write(sentDoc);
String sentContent = sentDoc.query("/sentence/@content").get(0).getValue();
Nodes neNodes = sentDoc.query("/sentence/ne");
Map<String,List<String>> neMap = new HashMap<String,List<String>>();
for (int j=0;j<neNodes.size();j++) {
Element e = (Element)neNodes.get(j);
String fromto = e.getAttributeValue("cfrom") + ":" + e.getAttributeValue("cto");
String safid = e.getAttributeValue("safid").substring(1);
if(!neMap.containsKey(fromto)) neMap.put(fromto, new ArrayList<String>());
neMap.get(fromto).add(safid);
}
System.out.println(neMap);
int docId = Integer.parseInt(sentDoc.query("/sentence/@docid").get(0).getValue());
if(!paperIdToPath.containsKey(docId)) {
Document paperDoc = rdbr.getPaperInfo(docId);
paperIdToPath.put(docId, paperDoc.query("/paper/@oscarpath").get(0).getValue());
}
if(!pathToSaf.containsKey(paperIdToPath.get(docId))) {
pathToSaf.put(paperIdToPath.get(docId), new Builder().build(new File(paperIdToPath.get(docId), "saf.xml")));
File newSaf = new File(new File("/usr/groups/sciborg/texts/ne_annotated_210409/", new File(paperIdToPath.get(docId)).getName()), "saf.xml");