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

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


   
    int nb = 0;
    int b = 0;
   
    for(int i=0;i<n.size();i++) {
      TokenSequence t = Tokeniser.getInstance().tokenise(n.get(i).getValue());
      boolean isBoring = true;
      for(String s : t.getTokenStringList()) {
        s = StringTools.normaliseName(s);
        if(!s.matches(".*[A-Za-z].*")) continue;
        if(boring.contains(s)) continue;
        boring.add(s);
        isBoring = false;
View Full Code Here


   
    Bag<String> wordCounts = new Bag<String>();
   
    ss.reset();
    for(String s : ss) {
      TokenSequence t = Tokeniser.getInstance().tokenise(s);
      for(String word : t.getTokenStringList()) {
        if(!word.matches(".*[a-z][a-z].*")) continue;
        word = StringTools.normaliseName(word);
        wordCounts.add(word);
      }
    } 
View Full Code Here

    Collections.sort(offsetArray, offsetComparator);
    System.out.println(System.currentTimeMillis() - time)
  }
 
  public int [] searchForString(String searchString) {
    TokenSequence ts = Tokeniser.getInstance().tokenise(searchString);
    List<Integer> tsl = new ArrayList<Integer>(ts.size() + 1);
    for(Token t : ts.getTokens()) {
      String s = t.getValue().toLowerCase();
      if(tokenIndex.containsKey(s)) {
        tsl.add(tokenIndex.get(s));
      } else {
        return null;
View Full Code Here

      Token token = procDoc.getTokenByStart(e.getAttributeValue("from"));
      if(token == null) token = procDoc.getTokenByEnd(e.getAttributeValue("to"));
      if(token == null) {
        System.out.println("Eeep!");
      } else {
        TokenSequence tokSeq = token.getTokenSequence();
        boolean isReact = "REACT".equals(SafTools.getSlotValue(e, "subtype"));
        if(tokSeqs.containsKey(tokSeq)) {
          if(isReact) tokSeqs.put(tokSeq, true);
        } else {
          tokSeqs.put(tokSeq, isReact);
View Full Code Here

        c = reader.read();
      }     
    } catch (Exception e) {
      throw new Error(e);
    }
    TokenSequence t = Tokeniser.getInstance().tokenise(sb.toString());
   
    TokenStream ts = new Oscar3TokenStream(t);
    ts = new Oscar3Filters(ts);
    return ts;
  }
View Full Code Here

      Token token = procDoc.getTokenByStart(e.getAttributeValue("from"));
      if(token == null) token = procDoc.getTokenByEnd(e.getAttributeValue("to"));
      if(token == null) {
        System.out.println("Eeep!");
      } else {
        TokenSequence tokSeq = token.getTokenSequence();
        //boolean isReact = "REACT".equals(SafTools.getSlotValue(e, "subtype"));
        boolean isPubmed = f.toString().contains("pubmed");
        if(tokSeqs.containsKey(tokSeq)) {
          if(isPubmed) tokSeqs.put(tokSeq, true);
        } else {
View Full Code Here

   
    File f = new File("/home/ptc24/tmp/yahoo/" + word + ".txt");
    List<String> strings = FileTools.getStrings(new FileInputStream(f));
    Bag<String> collocs = new Bag<String>();
    for(String s : strings) {
      TokenSequence t = Tokeniser.getInstance().tokenise(s);
      List<String> tokens = t.getTokenStringList();
      boolean hasCell = false;
      for(String token : tokens) {
        if(token.toLowerCase().equals(word)) {
          hasCell = true;
          break;
View Full Code Here

    //files = files.subList(0, 10);
   
   
    Bag<String> tokenBag = new Bag<String>();
   
    TokenSequenceSource tss = new TokenSequenceSource(files);
    int i=0;
    for(TokenSequence ts : tss) {
      for(Token t : ts.getTokens()) {
        tokenBag.add(t.getValue().intern());
      }
View Full Code Here

      corpusOffset++;
    }
  }
 
  public InverseSearcher(List<File> files) throws Exception {
    TokenSequenceSource tss = new TokenSequenceSource(files);

    corpusArray = new ArrayList<Integer>();
    offsetArray = new ArrayList<Integer>();
    tokenList = new ArrayList<String>();
    tokenIndex = new HashMap<String,Integer>();
View Full Code Here

    }
    Bag<String> allTerms = new Bag<String>();
    String word = "reduction";
    List<File> files = FileTools.getFilesFromDirectoryByName(new File("/home/ptc24/newows/corpora/BioIE"), "source.xml");
    //List<File> files = FileTools.getFilesFromDirectoryByName(new File("/scratch/pubmed/2005"), "source.xml");
    TokenSequenceSource ts = new TokenSequenceSource(files);
    for(TokenSequence t : ts) {
      List<String> tokens = t.getTokenStringList();
      for(int i=0;i<tokens.size();i++) {
        if(tokens.get(i).equals(word)) {
          for(int j=Math.max(0, i-windowSize);j<=Math.min(i+windowSize,tokens.size()-1);j++) {
View Full Code Here

TOP

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

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.