Package uk.ac.cam.ch.wwmm.oscar3.indexersearcher

Examples of uk.ac.cam.ch.wwmm.oscar3.indexersearcher.LuceneIndexerSearcher


    //pq.add(new Term("txt", "aromatase"));
    //pq.add(new Term("txt", "inhibitors"));
    //Query q = new TermQuery(new Term("txt", queryTerm));
    Query q = new StemQuery(new Term("txt", queryTerm), stemmerTools);
    //q = pq;
    VectorCollector vc = new VectorCollector();
    is.search(q, vc);
    Map<String,Double> scores = simpleExcessAnalyseCluster(vc.getResultsVector(), lis.getIndexReader(), 0.01);
    for(String s : StringTools.getSortedList(scores)) {
      System.out.println(s + "\t" + scores.get(s));
    }

    //tfIdfAnalyseCluster(vc.getResultsVector(), lis.getIndexReader());
View Full Code Here


    String normWord = StringTools.normaliseName(word);
    if (!word.equals(normWord)) {
      contextable.add(makeWordFeature(normWord));
    }

    ExtractTrainingData etd = ExtractTrainingData.getInstance();
    makeWordFeatures(word, normWord, bigramable, etd);
    makeReactionFeatures(word, bigramable, contextable, etd);

    String wts = StringTools.removeTerminalS(normWord);
    contextable.add(WITHOUT_TERMINAL_S_FEATURE + wts);
View Full Code Here

  // I'm sure there's a nice analytic way of doing this. Ah well...
  public static void main(String[] args) {
    List<Double> positiveExamples = new ArrayList<Double>();
    List<Double> negativeExamples = new ArrayList<Double>();
   
    ExtractTrainingData etd1 = ExtractTrainingData.getInstance();
    List<File> sbFiles = new ArrayList<File>();
    sbFiles.addAll(FileTools.getFilesFromDirectoryByName(new File("/home/ptc24/newows/goodrsc"), "scrapbook.xml"));
    ExtractTrainingData etd2 = new ExtractTrainingData(sbFiles);
    Set<String> chem = new HashSet<String>(etd2.chemicalWords);
    //chem.removeAll(etd1.chemicalWords);
    for(String w : chem) {
      if(!NGramBuilder.getInstance().chemSet.contains(NGram.parseWord(w))) {
        double score = NGram.getInstance().testWord(w);
View Full Code Here

    }   
  }

  private boolean resolveVsNewPubChem(ProcessState state, String name) {
    try {
      NewPubChem npc = NewPubChem.getInstance();
      if(npc != null) {
        String [] results = npc.getShortestSmilesAndInChI(name);
        if(results == null) return false;
        state.smiles = results[0];
        state.inchi = results[1];
        if(state.smiles != null) setNEAttribute(state.ne, "SMILES", state.smiles);
        if(state.inchi != null) setNEAttribute(state.ne, "InChI", state.inchi);
View Full Code Here

      }
      return;
    }
   
    if(mode.equals("BuildPubChem")) {
      new NewPubChem().initialise();
      return;
    }
   
    if(mode.equals("Server")) {
      if(Oscar3Props.getInstance().serverType.equals("none")) {
View Full Code Here

    String type = a.type;
    //System.out.println(surface + " " + a.type);
    if(type.contains("_")) {
      type = type.split("_")[0];
    }
    NamedEntity ne = new NamedEntity(t.getTokens(a.startToken, endToken), surface, type);
    assert(collector instanceof NECollector);
    ((NECollector)collector).collect(ne);
    //System.out.println(surface + ": " + a.reps);
    if(a.type.startsWith("ONT")) {
      Set<String> ontIds = runAutToStateToOntIds.get(a.type).get(a.state);
      String s = OntologyTerms.idsForTerm(surface);
      if(s != null && s.length() > 0) {
        if(ontIds == null) ontIds = new HashSet<String>();
        ontIds.addAll(StringTools.arrayToList(s.split("\\s+")));       
      }
      ne.addOntIds(ontIds);
      //System.out.println(surface + "\t" + ontIds);
    }
    if(a.type.startsWith("CUST")) {
      Set<String> custTypes = runAutToStateToOntIds.get(a.type).get(a.state);
      ne.addCustTypes(custTypes);
      //System.out.println(surface + "\t" + ontIds);
    }
    //ne.setPattern(StringTools.collectionToString(a.getReps(), "_"));
  }
View Full Code Here

    String type = a.type;
    //System.out.println(surface + " " + a.type);
    if(type.contains("_")) {
      type = type.split("_")[0];
    }
    NamedEntity ne = new NamedEntity(t.getTokens(a.startToken, endToken), surface, type);
    assert(collector instanceof NECollector);
    ((NECollector)collector).collect(ne);
    //System.out.println(surface + ": " + a.reps);
    if(a.type.startsWith("ONT")) {
      Set<String> ontIds = runAutToStateToOntIds.get(a.type).get(a.state);
      String s = OntologyTerms.idsForTerm(StringTools.normaliseName(surface));
      if(s != null && s.length() > 0) {
        if(ontIds == null) ontIds = new HashSet<String>();
        ontIds.addAll(StringTools.arrayToList(s.split("\\s+")));       
      }
      ne.addOntIds(ontIds);
      //System.out.println(surface + "\t" + ontIds);
    }
    if(a.type.startsWith("CUST")) {
      //System.out.println(runAutToStateToOntIds.get(a.type));
      Set<String> custTypes = runAutToStateToOntIds.get(a.type).get(a.state);
      ne.addCustTypes(custTypes);
      //System.out.println(surface + "\t" + ontIds);
    }

    //ne.setPattern(StringTools.collectionToString(a.getReps(), "_"));
  }
View Full Code Here

        String value = token.getValue();
        value = value.toLowerCase();
        if(prwStrings.contains(value)) {
          List<Token> neTokens = new ArrayList<Token>();
          neTokens.add(token);
          NamedEntity ne = new NamedEntity(neTokens, token.getValue(), "PRW");
          safholder.appendChild(ne.toSAF());
          //System.out.println("**********");
        }
      }
      //System.out.println();
    }
 
View Full Code Here

          } else {
            featuresForAbbrev = new ArrayList<String>();
            abbrevFeatures.put(ne.getSurface(), featuresForAbbrev);
          }
          if(neByLastToken.containsKey(prev2)) {
            NamedEntity maybeAbbrev = neByLastToken.get(prev2);
            String abbrMode = "abbr1:";
            if(StringTools.testForAcronym(surf, maybeAbbrev.getSurface())) {
              abbrMode = "abbr2:";
            }
            if(surf.matches(".*\\s.*")) abbrMode += "wws:";
            for(double lthresh = -5.0;lthresh < 5.05;lthresh += 0.5) {
              double thresh = logitToProb(lthresh);
              if(maybeAbbrev.getConfidence() > thresh) {
                featuresForAbbrev.add(abbrMode + "abbr>" + thresh);
              } else {
                featuresForAbbrev.add(abbrMode + "abbr<" + thresh);
              }             
            }
View Full Code Here

 
  private static NamedEntity makeNE(List<Token> neTokens, String neType) {
    Token firstToken = neTokens.get(0);
    Token lastToken = neTokens.get(neTokens.size()-1);
    String surf = firstToken.getTokenSequence().getSubstring(firstToken.getId(), lastToken.getId());
    return new NamedEntity(neTokens, surf, "GENIA-" + neType);
  }
View Full Code Here

TOP

Related Classes of uk.ac.cam.ch.wwmm.oscar3.indexersearcher.LuceneIndexerSearcher

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.