public final void annotate ( final InputStream inputStream , final OutputStream outputStream ) throws IOException , JDOMException { final String model = this . parsedArguments . getString ( "model" ) ; final String lemmatizerModel = this . parsedArguments . getString ( "lemmatizerModel" ) ; final boolean allMorphology = this . parsedArguments . getBoolean ( "allMorphology" ) ; final String multiwords = Boolean . toString ( this . parsedArguments . getBoolean ( "multiwords" ) ) ; final String dictag = Boolean . toString ( this . parsedArguments . getBoolean ( "dictag" ) ) ; String outputFormat = parsedArguments . getString ( "outputFormat" ) ; BufferedReader breader = null ; BufferedWriter bwriter = null ; breader = new BufferedReader ( new InputStreamReader ( System . in , "UTF-8" ) ) ; bwriter = new BufferedWriter ( new OutputStreamWriter ( System . out , "UTF-8" ) ) ; final KAFDocument kaf = KAFDocument . createFromStream ( breader ) ; // language String lang ; if ( this . parsedArguments . getString ( "language" ) != null ) { lang = this . parsedArguments . getString ( "language" ) ; if ( ! kaf . getLang ( ) . equalsIgnoreCase ( lang ) ) { System . err . println ( "Language parameter in NAF and CLI do not match!!" ) ; // System.exit(1); } } else { lang = kaf . getLang ( ) ; } final Properties properties = setAnnotateProperties ( model , lemmatizerModel , lang , multiwords , dictag ) ; final Annotate annotator = new Annotate ( properties ) ; final KAFDocument . LinguisticProcessor newLp = kaf . addLinguisticProcessor ( "terms" , "ixa-pipe-pos-" + Files . getNameWithoutExtension ( model ) , this . version + "-" + this . commit ) ; newLp . setBeginTimestamp ( ) ; if ( allMorphology ) { if ( outputFormat . equalsIgnoreCase ( "conll" ) ) { bwriter . write ( annotator . getAllTagsLemmasToCoNLL ( kaf ) ) ; } else { annotator . getAllTagsLemmasToNAF ( kaf ) ; newLp . setEndTimestamp ( ) ; bwriter . write ( kaf . toString ( ) ) ; } } else { if ( outputFormat . equalsIgnoreCase ( "conll" ) ) { bwriter . write ( annotator . annotatePOSToCoNLL ( kaf ) ) ; } else { annotator . annotatePOSToKAF ( kaf ) ; newLp . setEndTimestamp ( ) ; bwriter . write ( kaf . toString ( ) ) ; } } bwriter . close ( ) ; breader . close ( ) ; }
Main entry point for annotation . Takes system . in as input and outputs annotated text via system . out .