public static String dumpArguments ( JCas jCas , boolean includeProperties , boolean includeRelations ) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( ) ; PrintStream out = new PrintStream ( outputStream ) ; String documentId = DocumentMetaData . get ( jCas ) . getDocumentId ( ) ; out . println ( "======== #" + documentId + " begin ==========================" ) ; Collection < ArgumentComponent > argumentComponents = JCasUtil . select ( jCas , ArgumentComponent . class ) ; out . println ( "----------------- ArgumentComponent -----------------" ) ; out . println ( "# of argument units: " + argumentComponents . size ( ) ) ; for ( ArgumentComponent argumentComponent : argumentComponents ) { out . println ( argumentUnitToString ( argumentComponent ) ) ; if ( includeProperties ) { out . println ( formatProperties ( argumentComponent ) ) ; } if ( argumentComponent instanceof Claim ) { Claim claim = ( Claim ) argumentComponent ; String stance = claim . getStance ( ) ; if ( stance != null ) { out . println ( "Stance: " + stance ) ; } } } Collection < ArgumentRelation > argumentRelations = JCasUtil . select ( jCas , ArgumentRelation . class ) ; if ( includeRelations ) { out . println ( "----------------- ArgumentRelation -----------------" ) ; out . println ( "# of argument relations: " + argumentRelations . size ( ) ) ; for ( ArgumentRelation argumentRelation : argumentRelations ) { out . println ( argumentRelation . getType ( ) . getShortName ( ) ) ; out . println ( " source: " + argumentUnitToString ( argumentRelation . getSource ( ) ) ) ; out . println ( " target: " + argumentUnitToString ( argumentRelation . getTarget ( ) ) ) ; if ( includeProperties ) { out . println ( formatProperties ( argumentRelation ) ) ; } } } out . println ( "======== #" + documentId + " end ==========================" ) ; try { return outputStream . toString ( "utf-8" ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } }
Dump argument components to String . Can be also used outside UIMA pipeline .