public Map<Integer, Integer> getGeneSpansCRF(CRF crf, String text) {
    Map<Integer, Integer> begin2end = new HashMap<Integer, Integer>();
    Annotation document = new Annotation(text);
    pipeline.annotate(document);
    List<CoreMap> sentences = document.get(SentencesAnnotation.class);

    for (CoreMap sentence : sentences) {
      StringBuffer sb = new StringBuffer();
      for (CoreLabel token : sentence.get(TokensAnnotation.class)) {
        // Add target only for adaptable for the training pipeline!
        // target " O" is never used!
        // The input file does not contain tags (aka targets)
        sb.append(token.value() + " O"+ "\n");
      }
      sb.append("\n");

      // test
      Pipe p = crf.getInputPipe();

      InstanceList applyData = new InstanceList(p);
      applyData.addThruPipe(new LineGroupIterator(new BufferedReader(new InputStreamReader(
              new ByteArrayInputStream(sb.toString().getBytes()))), Pattern.compile("^$"), true));

      Iterator iter = applyData.iterator();
      while(iter.hasNext()) {
        Sequence outseq = crf.transduce((Sequence)((Instance) iter.next()).getData());
        // retrive result
        int idx = 0;
        List<CoreLabel> list = new ArrayList<CoreLabel>();
        
        for (CoreLabel token : sentence.get(TokensAnnotation.class)) {
          if(!outseq.get(idx++).equals(OGM))
            list.add(token);
          else if(list.size() > 0) {
            int begin = list.get(0).beginPosition(); 
            int end = list.get(list.size()-1).endPosition(); 
            begin2end.put(begin, end); 
            list.clear();
          }
        }
        if(list.size() > 0) {
          int begin = list.get(0).beginPosition(); 
          int end = list.get(list.size()-1).endPosition(); 
          begin2end.put(begin, end); 
          list.clear();
        }
      }
    }
    return begin2end;
  }