Package org.mitre.medfacts.zoner

Examples of org.mitre.medfacts.zoner.ZonerCli$Range


    } catch (URISyntaxException e1)
    {
      logger.error( String.format("section regex file not found [%s]", sectionRegexFileUriString), e1);
      throw new AnalysisEngineProcessException(e1);
    }
    ZonerCli zonerCli =
      new ZonerCli(sectionRegexFileInClasspathUri);
   
    zonerCli.setEntireContents(jcas.getDocumentText());
    // initialize converter once contents are set
    zonerCli.initialize();
    try {
      zonerCli.execute();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      return;
      //throw new AnalysisEngineProcessException(e);
    } catch (StringIndexOutOfBoundsException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      System.out.format("string index out of bounds exception count: %d%n", ++countOfIndexOutOfBounds);
      return;
      //throw new AnalysisEngineProcessException(e);
    }
    // Add the zone annotations
    List<Range> rangeList = zonerCli.getRangeList();
    for (Iterator<Range> i = rangeList.iterator(); i.hasNext()) {
      Range r = i.next();
        Zone zAnnot = new Zone(jcas)
        zAnnot.setBegin(r.getBegin());
        zAnnot.setEnd(r.getEnd());
        zAnnot.setLabel(r.getLabel());
        zAnnot.addToIndexes();
        logger.info(String.format("added new zone annotation [%d-%d] \"%s\"", zAnnot.getBegin(), zAnnot.getEnd(), zAnnot.getCoveredText()));
    }
   
//    List<Range> subsectionRangeList = zonerCli.getSubsections();
//    for (Iterator<Range> i = subsectionRangeList.iterator(); i.hasNext();  ) {
//      Range r = i.next();
//        Subzone sAnnot = new Subzone(jcas); 
//        sAnnot.setBegin(r.getBegin());
//        sAnnot.setEnd(r.getEnd());
//        sAnnot.setLabel(r.getLabel());
//        sAnnot.addToIndexes();
//        logger.info(String.format("added new subzone annotation [%d-%d] \"%s\"", sAnnot.getBegin(), sAnnot.getEnd(), sAnnot.getCoveredText()));
//    }
   
   
   
    // Add the heading annotations
    List<HeadingRange> headings = zonerCli.getHeadings();
    for (Iterator<HeadingRange> i = headings.iterator(); i.hasNext()) {
      HeadingRange r = i.next();
        Heading hAnnot = new Heading(jcas)
        hAnnot.setBegin(r.getHeadingBegin());
        hAnnot.setEnd(r.getHeadingEnd());
View Full Code Here


    } catch (URISyntaxException e1)
    {
      logger.log(Level.SEVERE, String.format("section regex file not found [%s]", sectionRegexFileUriString), e1);
      throw new AnalysisEngineProcessException(e1);
    }
    ZonerCli zonerCli =
      new ZonerCli(sectionRegexFileInClasspathUri);
   
    zonerCli.setEntireContents(jcas.getDocumentText());
    // initialize converter once contents are set
    zonerCli.initialize();
    try {
      zonerCli.execute();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      return;
      //throw new AnalysisEngineProcessException(e);
    } catch (StringIndexOutOfBoundsException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      System.out.format("string index out of bounds exception count: %d%n", ++countOfIndexOutOfBounds);
      return;
      //throw new AnalysisEngineProcessException(e);
    }
    // Add the zone annotations
    List<Range> rangeList = zonerCli.getRangeList();
    for (Iterator<Range> i = rangeList.iterator(); i.hasNext()) {
      Range r = i.next();
        Zone zAnnot = new Zone(jcas)
        zAnnot.setBegin(r.getBegin());
        zAnnot.setEnd(r.getEnd());
        zAnnot.setLabel(r.getLabel());
        zAnnot.addToIndexes();
        logger.info(String.format("added new zone annotation [%d-%d] \"%s\"", zAnnot.getBegin(), zAnnot.getEnd(), zAnnot.getCoveredText()));
    }
   
//    List<Range> subsectionRangeList = zonerCli.getSubsections();
//    for (Iterator<Range> i = subsectionRangeList.iterator(); i.hasNext();  ) {
//      Range r = i.next();
//        Subzone sAnnot = new Subzone(jcas); 
//        sAnnot.setBegin(r.getBegin());
//        sAnnot.setEnd(r.getEnd());
//        sAnnot.setLabel(r.getLabel());
//        sAnnot.addToIndexes();
//        logger.info(String.format("added new subzone annotation [%d-%d] \"%s\"", sAnnot.getBegin(), sAnnot.getEnd(), sAnnot.getCoveredText()));
//    }
   
   
   
    // Add the heading annotations
    List<HeadingRange> headings = zonerCli.getHeadings();
    for (Iterator<HeadingRange> i = headings.iterator(); i.hasNext()) {
      HeadingRange r = i.next();
        Heading hAnnot = new Heading(jcas)
        hAnnot.setBegin(r.getHeadingBegin());
        hAnnot.setEnd(r.getHeadingEnd());
View Full Code Here

    } catch (URISyntaxException e1)
    {
      logger.error( String.format("section regex file not found [%s]", sectionRegexFileUriString), e1);
      throw new AnalysisEngineProcessException(e1);
    }
    ZonerCli zonerCli =
      new ZonerCli(sectionRegexFileInClasspathUri);
   
    zonerCli.setEntireContents(jcas.getDocumentText());
    // initialize converter once contents are set
    zonerCli.initialize();
    try {
      zonerCli.execute();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      return;
      //throw new AnalysisEngineProcessException(e);
    } catch (StringIndexOutOfBoundsException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      System.out.format("string index out of bounds exception count: %d%n", ++countOfIndexOutOfBounds);
      return;
      //throw new AnalysisEngineProcessException(e);
    }
    // Add the zone annotations
    List<Range> rangeList = zonerCli.getRangeList();
    for (Iterator<Range> i = rangeList.iterator(); i.hasNext()) {
      Range r = i.next();
        Zone zAnnot = new Zone(jcas)
        zAnnot.setBegin(r.getBegin());
        zAnnot.setEnd(r.getEnd());
        zAnnot.setLabel(r.getLabel());
        zAnnot.addToIndexes();
        logger.info(String.format("added new zone annotation [%d-%d] \"%s\"", zAnnot.getBegin(), zAnnot.getEnd(), zAnnot.getCoveredText()));
    }
   
//    List<Range> subsectionRangeList = zonerCli.getSubsections();
//    for (Iterator<Range> i = subsectionRangeList.iterator(); i.hasNext();  ) {
//      Range r = i.next();
//        Subzone sAnnot = new Subzone(jcas); 
//        sAnnot.setBegin(r.getBegin());
//        sAnnot.setEnd(r.getEnd());
//        sAnnot.setLabel(r.getLabel());
//        sAnnot.addToIndexes();
//        logger.info(String.format("added new subzone annotation [%d-%d] \"%s\"", sAnnot.getBegin(), sAnnot.getEnd(), sAnnot.getCoveredText()));
//    }
   
   
   
    // Add the heading annotations
    List<HeadingRange> headings = zonerCli.getHeadings();
    for (Iterator<HeadingRange> i = headings.iterator(); i.hasNext()) {
      HeadingRange r = i.next();
        Heading hAnnot = new Heading(jcas)
        hAnnot.setBegin(r.getHeadingBegin());
        hAnnot.setEnd(r.getHeadingEnd());
View Full Code Here

  }

  public static List<ZoneAnnotation> findZones(String entireContents, String textLookup[][], CharacterOffsetToLineTokenConverter converter)
  {
    ZonerCli zoner = new ZonerCli();
    zoner.setConverter(converter);
    zoner.setEntireContents(entireContents);
    zoner.findHeadings();
    List<Range> zonerRangeList = zoner.getFullRangeListAdjusted();

    ArrayList<ZoneAnnotation> tempZoneAnnotationList =
        new ArrayList<ZoneAnnotation>();

    for (Range currentRange : zonerRangeList)
View Full Code Here

        Array dataArray = Array.factory(DataType.FLOAT, section.getShape());
        GradsVariable gradsVar = findVar(v2);

        // Canonical ordering is ens, time, level, lat, lon
        int           rangeIdx  = 0;
        Range         ensRange  = (gradsDDF.getEnsembleDimension() != null)
                                  ? section.getRange(rangeIdx++)
                                  : new Range(0, 0);
        Range         timeRange = (section.getRank() > 2)
                                  ? section.getRange(rangeIdx++)
                                  : new Range(0, 0);
        Range         levRange  = (gradsVar.getNumLevels() > 0)
                                  ? section.getRange(rangeIdx++)
                                  : new Range(0, 0);
        Range         yRange    = section.getRange(rangeIdx++);
        Range         xRange    = section.getRange(rangeIdx);

        IndexIterator ii        = dataArray.getIndexIterator();

        // loop over ens
        for (int ensIdx = ensRange.first(); ensIdx <= ensRange.last();
View Full Code Here

    // create the List<Dim>
    // Section shifted = intersect.shiftOrigin(dataSection); // want reletive to dataSection
    int wantStride = 1;
    int dataStride = 1;
    for (int ii = varRank - 1; ii >= 0; ii--) {
      Range dr = dataSection.getRange(ii);
      Range wr = wantSection.getRange(ii);
      Range ir = intersect.getRange(ii);
      dimList.add(new Dim(dr, wr, ir, dataStride, wantStride)); // note reversed : fastest first
      dataStride *= dr.length();
      wantStride *= wr.length();
    }

View Full Code Here

     * @throws InvalidRangeException  range doesn't match data
     */
    public Array readVariable(Variable v2, Section section)
            throws IOException, InvalidRangeException {

        Range timeRange = null;
        Range bandRange = null;
        Range geoXRange = null;
        Range geoYRange = null;
        if (section != null & section.getRank() > 0) {
            if (section.getRank() > 3) {
                timeRange = (Range) section.getRange(0);
                bandRange = (Range) section.getRange(1);
                geoYRange = (Range) section.getRange(2);
                geoXRange = (Range) section.getRange(3);
            } else if (section.getRank() > 2) {
                timeRange = (Range) section.getRange(0);
                geoYRange = (Range) section.getRange(1);
                geoXRange = (Range) section.getRange(2);
            } else if (section.getRank() > 1) {
                geoYRange = (Range) section.getRange(0);
                geoXRange = (Range) section.getRange(1);
            } else {
                geoXRange = (Range) section.getRange(0);
            }
        }

        String varname = v2.getFullName();

        Array dataArray =
            Array.factory(v2.getDataType().getPrimitiveClassType(),
                          section.getShape());

        Index dataIndex = dataArray.getIndex();

        if (varname.equals("latitude") || varname.equals("longitude")) {
            double[][] pixel = new double[2][1];
            double[][] latLon;
            double[][][] latLonValues =
                new double[geoXRange.length()][geoYRange.length()][2];

            // Use Range object, which calculates requested i, j
            // values and incorporates stride
            for (int i = 0; i < geoXRange.length(); i++) {
                for (int j = 0; j < geoYRange.length(); j++) {
                    pixel[0][0] = (double) geoXRange.element(i);
                    pixel[1][0] = (double) geoYRange.element(j);
                    latLon      = nav.toLatLon(pixel);

                    if (varname.equals("lat")) {
                        dataArray.setFloat(dataIndex.set(j, i),
                                           (float) (latLon[0][0]));
                    } else {
                        dataArray.setFloat(dataIndex.set(j, i),
                                           (float) (latLon[1][0]));
                    }
                }
            }
        }

        if (varname.equals("image")) {
            try {
                int[][] pixelData = new int[1][1];
                if (bandRange != null) {
                    for (int k = 0; k < bandRange.length(); k++) {
                        int bandIndex = bandRange.element(k) + 1// band numbers in McIDAS are 1 based
                        for (int j = 0; j < geoYRange.length(); j++) {
                            for (int i = 0; i < geoXRange.length(); i++) {
                                pixelData = af.getData(geoYRange.element(j),
                                        geoXRange.element(i), 1, 1,
                                        bandIndex);
                                dataArray.setInt(dataIndex.set(0, k, j, i),
                                        (pixelData[0][0]));
                            }
                        }
                    }

                } else {
                    for (int j = 0; j < geoYRange.length(); j++) {
                        for (int i = 0; i < geoXRange.length(); i++) {
                            pixelData = af.getData(geoYRange.element(j),
                                    geoXRange.element(i), 1, 1);
                            dataArray.setInt(dataIndex.set(0, j, i),
                                             (pixelData[0][0]));
                        }
                    }
View Full Code Here

        groups = volScan.getWidthGroups();
      else if( shortName.startsWith("DiffReflectivity"))
        groups = volScan.getDifferentialReflectivityGroups();

      if(section.getRank() == 2) {
          Range radialRange = section.getRange(0);
          Range gateRange = section.getRange(1);
          List lli = (List)groups.get(0);
          readOneScan(lli, radialRange, gateRange, ii);
      } else {
          Range scanRange = section.getRange(0);
          Range radialRange = section.getRange(1);
          Range gateRange = section.getRange(2);
          for (int i=scanRange.first(); i<=scanRange.last(); i+= scanRange.stride()) {
            readOneScan((List)groups.get(i), radialRange, gateRange, ii);
          }
      }
      return data;
View Full Code Here

    boolean tRangeDone = false;

    try
    {
      // Get the height range.
      Range zRange = vertSubset != null ? vertSubset.getRange() : null;
      zRangeDone = true;

      // Get the time range.
      Range tRange = null;
      if ( timeRange != null )
      {
        CoordinateAxis1DTime timeAxis = this.coordSys.getTimeAxis1D();
        int startIndex = timeAxis.findTimeIndexFromDate( timeRange.getStart().getDate() );
        int endIndex = timeAxis.findTimeIndexFromDate( timeRange.getEnd().getDate() );
        tRange = new Range( startIndex, endIndex );
        tRangeDone = true;
      }

      if ( format == WcsRequest.Format.GeoTIFF || format == WcsRequest.Format.GeoTIFF_Float )
      {
View Full Code Here

      GridDatatype grid = gds.findGridDatatype(gridName);
      GridCoordSystem gcsOrg = grid.getCoordinateSystem();
      CoordinateAxis1DTime timeAxis = gcsOrg.getTimeAxis1D();

      // make subset if needed
      Range timeRange = null;
      if ((dateRange != null) && (timeAxis != null)) {
        int startIndex = timeAxis.findTimeIndexFromDate(dateRange.getStart().getDate());
        int endIndex = timeAxis.findTimeIndexFromDate(dateRange.getEnd().getDate());
        if (startIndex < 0)
          throw new InvalidRangeException("start time=" + dateRange.getStart().getDate() + " must be >= " + timeAxis.getTimeDate(0));
        if (endIndex < 0)
          throw new InvalidRangeException("end time=" + dateRange.getEnd().getDate() + " must be >= " + timeAxis.getTimeDate(0));
        timeRange = new Range(startIndex, endIndex);
      }

      if ((null != timeRange) || (zRange != null) || (llbb != null) || (horizStride > 1)) {
        grid = grid.makeSubset(timeRange, zRange, llbb, 1, horizStride, horizStride);
      }
View Full Code Here

TOP

Related Classes of org.mitre.medfacts.zoner.ZonerCli$Range

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.