Package uk.ac.cam.ch.wwmm.oscar3.recogniser.test

Examples of uk.ac.cam.ch.wwmm.oscar3.recogniser.test.MEMMRecogniserTest


   * @throws Exception
   */
  public static Document makeModel() throws Exception {
    Element modelRoot = new Element("model");
    modelRoot.appendChild(ExtractTrainingData.getInstance().toXML());
    MEMM memm = MEMMSingleton.getInstance();
    if(memm != null) modelRoot.appendChild(memm.writeModel());
    NESubtypes subtypes = NESubtypes.getInstance();
    if(subtypes.OK) modelRoot.appendChild(subtypes.toXML());
    return new Document(modelRoot);
  }
View Full Code Here


      }     
    }*/
  }

  void trainOnSbFilesWithRescore(List<File> files, Map<File,String> domains) throws Exception {
    rescorer = new RescoreMEMMOut();
    List<List<File>> splitTrainFiles = new ArrayList<List<File>>();
    List<List<File>> splitTrainAntiFiles = new ArrayList<List<File>>();
    int splitNo = 3;
   
    for(int i=0;i<splitNo;i++) {
View Full Code Here

        tagSet.add(gm.getOutcome(j));
      }
    }
    Element rescorerElem = memmRoot.getFirstChildElement("rescorer");
    if(rescorerElem != null) {
      rescorer = new RescoreMEMMOut();
      rescorer.readElement(rescorerElem);
    } else {
      rescorer = null;
    }
    makeEntityTypesAndZeroProbs();
View Full Code Here

    //System.out.println(logAdd(-1000, -1000));
   
    //if(true) return;
   
    NGramBuilder ng = NGramBuilder.getInstance();
    ng.engSet.removeAll(ng.chemSet);
    Map<String,Boolean> isChem = new HashMap<String,Boolean>();
    for(String chem : ng.chemSet) {
      isChem.put(chem, true);
    }
View Full Code Here

  }
 
  private boolean resolveVsExternal(ProcessState state, String name) {
    if(extensionNameResolver == null) return false;
    try {
      Results results = extensionNameResolver.resolve(name, state.args);
      if(results != null) {
        state.smiles = results.getSmiles();
        state.inchi = results.getInchi();
        state.cmlMol = results.getCml();
        if(state.smiles != null) setNEAttribute(state.ne, "SMILES", state.smiles);
        if(state.inchi != null) setNEAttribute(state.ne, "InChI", state.inchi);
        if(state.smiles != null && Oscar3Props.getInstance().cacheExtensionNameResolver) {
          cacheEntry(name, state.smiles, state.inchi, state.cmlMol);
        }
View Full Code Here

  /**
   * @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");
View Full Code Here

  public static Document makeModel() throws Exception {
    Element modelRoot = new Element("model");
    modelRoot.appendChild(ExtractTrainingData.getInstance().toXML());
    MEMM memm = MEMMSingleton.getInstance();
    if(memm != null) modelRoot.appendChild(memm.writeModel());
    NESubtypes subtypes = NESubtypes.getInstance();
    if(subtypes.OK) modelRoot.appendChild(subtypes.toXML());
    return new Document(modelRoot);
  }
View Full Code Here

    long time = System.currentTimeMillis();
    ResourceGetter rg = new ResourceGetter("uk/ac/cam/ch/wwmm/oscar3/chemnamedict/resources/");
   
    Set<String> stops = rg.getStringSet("ChEBIStop.txt");
   
    OBOOntology o = OBOOntology.getInstance();

    Map<String,Set<String>> relatedBySource = new HashMap<String,Set<String>>();
   
    for(String id : o.getTerms().keySet()) {
      if(!id.startsWith("CHEBI:")) continue;
      //if(id.equals("CHEBI:16243")) System.out.println("foo!");
      OntologyTerm term = o.getTerms().get(id);
      Set<String> names = new LinkedHashSet<String>();
      names.add(term.getName());
      String inchi = null;
      String smiles = null;
      //System.out.println(term.getName());
View Full Code Here

    }
  }
 
  private Bag<String> expandOntologyBag(Bag<String> ontologyBag) {
    Bag<String> results = new Bag<String>();
    OBOOntology oo = OBOOntology.getInstance();
    for(String id : ontologyBag.getSet()) {
      for(String parent : oo.getIdsForIdWithAncestors(id)) {
        results.add(parent, ontologyBag.getCount(id));
      }
    }
    return results;
  }
View Full Code Here

    Map<String,Set<String>> relatedBySource = new HashMap<String,Set<String>>();
   
    for(String id : o.getTerms().keySet()) {
      if(!id.startsWith("CHEBI:")) continue;
      //if(id.equals("CHEBI:16243")) System.out.println("foo!");
      OntologyTerm term = o.getTerms().get(id);
      Set<String> names = new LinkedHashSet<String>();
      names.add(term.getName());
      String inchi = null;
      String smiles = null;
      //System.out.println(term.getName());
      for(Synonym s : term.getSynonyms()){
        //if(id.equals("CHEBI:16243")) System.out.println(s);
        //System.out.println("\t" + s);
        if(s.getType().equals("RELATED InChI")) {
          inchi = s.getSyn();
        } else if(s.getType().equals("RELATED SMILES")) {
View Full Code Here

TOP

Related Classes of uk.ac.cam.ch.wwmm.oscar3.recogniser.test.MEMMRecogniserTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.