Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.apache.ctakes.temporal.utils;
 
 import java.io.File;
 import java.util.List;
 
 import  org.cleartk.util.ViewUriUtil;
 import  org.cleartk.util.ae.UriToDocumentTextAnnotator;
 import  org.cleartk.util.cr.UriCollectionReader;
 
Checks Knowtator XML for possible annotation errors
 
 public class CheckKnowtatorAnnotations {
 
   private static interface Options {
 
     @Option(longName = "text")
     public File getRawTextDirectory();
 
     @Option(longName = "xml")
     public File getKnowtatorXMLDirectory();
 
     @Option(longName = "patients")
   }
 
   public static void main(String[] argsthrows Exception {
     Options options = CliFactory.parseArguments(Options.classargs);
     List<Filefiles = new ArrayList<File>();
     for (Integer set : options.getPatients().getList()) {
       File setTextDirectory = new File(options.getRawTextDirectory(), "doc" + set);
       for (File file : setTextDirectory.listFiles()) {
         files.add(file);
       }
     }
     CollectionReader reader = UriCollectionReader.getCollectionReaderFromFiles(files);
     AggregateBuilder builder = new AggregateBuilder();
     builder.add(UriToDocumentTextAnnotator.getDescription());
     builder.add(AnalysisEngineFactory.createEngineDescription(
         THYMEKnowtatorXMLReader.class,
         options.getKnowtatorXMLDirectory()));
     builder.add(AnalysisEngineFactory.createEngineDescription(SegmentsFromBracketedSectionTagsAnnotator.class));
     builder.add(AnalysisEngineFactory.createEngineDescription(
             SentenceDetector.class,
             .,
             "org/apache/ctakes/core/sentdetect/sd-med-model.zip"));
     builder.add(AnalysisEngineFactory.createEngineDescription(TokenizerAnnotatorPTB.class));
     for (Iterator<JCascasIter = new JCasIterator(readerbuilder.createAggregate()); casIter.hasNext();){
       JCas jCas = casIter.next();
       for (EventMention event : JCasUtil.select(jCasEventMention.class)) {
         List<BaseTokentokens = JCasUtil.selectCovered(jCasBaseToken.classevent);
         if (tokens.size() > 1) {
           ..printf(
               "Multi-token event \"%s\" in %s\n",
               event.getCoveredText(),
               ViewUriUtil.getURI(jCas));
         }
         if (event.getCoveredText().contains(" ")) {
           ..printf(
               "Whitespace in event \"%s\" in %s\n",
               event.getCoveredText(),
               ViewUriUtil.getURI(jCas));
        }
      }
    }
  }
New to GrepCode? Check out our FAQ X