private void processLeaf(Leaf leaf, List<String> sentence, List<Span> names) {

    if (leaf != null && leftContractionPart == null) {

      int startOfNamedEntity = -1;
      String leafTag = leaf.getSecondaryTag();

      if (leafTag != null) {
        if (leafTag.contains("<sam->")) {
          String[] lexemes = underlinePattern.split(leaf.getLexeme());
          if (lexemes.length > 1) {
            for (int i = 0; i < lexemes.length - 1; i++) {
              sentence.add(lexemes[i]);
              
              String[] conts = ContractionUtility.expand(lexemes[i]);
              if(conts != null) {
                int end = sentence.size();
                int start = end - 1;
                Span s = new Span(start, end, "default");
                names.add(s);
                {
                  Span[] ss = {s};
                  System.out.println(Arrays.toString(Span.spansToStrings(ss, sentence.toArray(new String[sentence.size()]))));
                }
              }
            }
          }
          leftContractionPart = lexemes[lexemes.length - 1];
          return;
        }
        // if (leaf.getLexeme().contains("_") && leaf.getLexeme().length() > 3)
        // {
        // String tag = leaf.getFunctionalTag();
        // if (tags != null) {
        // if (tags.contains(tag)) {
        // namedEntityTag = leaf.getFunctionalTag();
        // }
        // } else {
        // namedEntityTag = leaf.getFunctionalTag();
        // }
        // }
      }

      // if (contraction) {
      // startOfNamedEntity = sentence.size();
      // }
      //
      sentence.addAll(Arrays.asList(leaf.getLexeme()));// .split("_")
      //
      // if (contraction) {
      // names
      // .add(new Span(startOfNamedEntity, sentence.size()));
      // }

    } else {
      // will handle the contraction
      String tag = leaf.getSecondaryTag();
      String right = leaf.getLexeme();
      if (tag != null && tag.contains("<-sam>")) {
        String[] parts = underlinePattern.split(leaf.getLexeme());
        if(parts != null) {
          // try to join only the first
          String c = PortugueseContractionUtility.toContraction(
              leftContractionPart, parts[0]);

          if (c != null) {
            sentence.add(c);
            names.add(new Span(sentence.size() - 1, sentence.size(), "default"));
          }
          
          for (int i = 1; i < parts.length; i++) {
            sentence.add(parts[i]);
          }
        } else {
          right = leaf.getLexeme();
          String c = PortugueseContractionUtility.toContraction(
              leftContractionPart, right);

          if (c != null) {
            sentence.add(c);
            names.add(new Span(sentence.size() - 1, sentence.size(), "default"));
          } else {
            System.err.println("missing " + leftContractionPart + " + " + right);
            sentence.add(leftContractionPart);
            sentence.add(right);
          }
        }
      } else {
        System.err.println("unmatch" + leftContractionPart + " + " + right);
      }
      leftContractionPart = null;
    }

  }
private void processLeaf ( Leaf leaf , List < String > sentence , List < Span > names ) { if ( leaf != null && leftContractionPart == null ) { int startOfNamedEntity = - 1 ; String leafTag = leaf . getSecondaryTag ( ) ; if ( leafTag != null ) { if ( leafTag . contains ( "<sam->" ) ) { String [ ] lexemes = underlinePattern . split ( leaf . getLexeme ( ) ) ; if ( lexemes . length > 1 ) { for ( int i = 0 ; i < lexemes . length - 1 ; i ++ ) { sentence . add ( lexemes [ i ] ) ; String [ ] conts = ContractionUtility . expand ( lexemes [ i ] ) ; if ( conts != null ) { int end = sentence . size ( ) ; int start = end - 1 ; Span s = new Span ( start , end , "default" ) ; names . add ( s ) ; { Span [ ] ss = { s } ; System . out . println ( Arrays . toString ( Span . spansToStrings ( ss , sentence . toArray ( new String [ sentence . size ( ) ] ) ) ) ) ; } } } } leftContractionPart = lexemes [ lexemes . length - 1 ] ; return ; } } sentence . addAll ( Arrays . asList ( leaf . getLexeme ( ) ) ) ; } else { String tag = leaf . getSecondaryTag ( ) ; String right = leaf . getLexeme ( ) ; if ( tag != null && tag . contains ( "<-sam>" ) ) { String [ ] parts = underlinePattern . split ( leaf . getLexeme ( ) ) ; if ( parts != null ) { String c = PortugueseContractionUtility . toContraction ( leftContractionPart , parts [ 0 ] ) ; if ( c != null ) { sentence . add ( c ) ; names . add ( new Span ( sentence . size ( ) - 1 , sentence . size ( ) , "default" ) ) ; } for ( int i = 1 ; i < parts . length ; i ++ ) { sentence . add ( parts [ i ] ) ; } } else { right = leaf . getLexeme ( ) ; String c = PortugueseContractionUtility . toContraction ( leftContractionPart , right ) ; if ( c != null ) { sentence . add ( c ) ; names . add ( new Span ( sentence . size ( ) - 1 , sentence . size ( ) , "default" ) ) ; } else { System . err . println ( "missing " + leftContractionPart + " + " + right ) ; sentence . add ( leftContractionPart ) ; sentence . add ( right ) ; } } } else { System . err . println ( "unmatch" + leftContractionPart + " + " + right ) ; } leftContractionPart = null ; } }
Process a Leaf of Arvores Detaitadas format

@param leaf
the leaf to be processed
@param sentence
the sentence tokens we got so far
@param names
the names we got so far