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.eval;
public class I2B2Data {
  private static final int trainDevCutoff = 600;   // Nothing special here -- no dev set specified by i2b2 challenege, so I just split it up so there's about 150 train and 40 dev.
  
  static Pattern filePatt = Pattern.compile("(\\d+).xml");
  
  public static List<IntegergetTrainPatientSets(File xmlDirectory) {
    List<Integertrains = new ArrayList<>();
    
    File[] files = getAllFiles(xmlDirectory"training");
    Matcher m = null;
    for(File file : files){
      m = .matcher(file.getName());
      if(m.matches()){
        int ptNum = Integer.parseInt(m.group(1));
        if(ptNum < ){
          trains.add(ptNum);
        }
      }
    }
    return trains;
  }
  public static List<IntegergetDevPatientSets(File xmlDirectory) {
    List<Integerdevs = new ArrayList<>();
    File[] files = getAllFiles(xmlDirectory"training");
    Matcher m = null;
    
    for(File file : files){
      m = .matcher(file.getName());
      if(m.matches()){
        int ptNum = Integer.parseInt(m.group(1));
        if(ptNum >= ){
          devs.add(ptNum);
        }
      }
    }
    return devs;
  }
  public static List<IntegergetTestPatientSets(File xmlDirectory) {
    List<Integertests = new ArrayList<>();
    File[] files = getAllFiles(xmlDirectory"test");
    Matcher m = null;
    
    for(File file : files){
      m = .matcher(file.getName());
      if(m.matches()){
        int ptNum = Integer.parseInt(m.group(1));
        tests.add(ptNum);
      }
    }
    return tests;
  }
  
  private static File[] getAllFiles(File xmlDirectoryString sub){
    return new File(xmlDirectorysub).listFiles(new FilenameFilter() {      
      public boolean accept(File dirString name) {
        return name.endsWith(".xml");
      }
    });
  }
New to GrepCode? Check out our FAQ X