<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> import argparse <EOL> import logging <EOL> import re <EOL> import google . cloud . dataflow as df <EOL> def run ( argv = None ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( ) <EOL> parser . add_argument ( '<STR_LIT>' , <EOL> dest = '<STR_LIT:input>' , <EOL> default = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , <EOL> dest = '<STR_LIT>' , <EOL> default = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> known_args , pipeline_args = parser . parse_known_args ( argv ) <EOL> pipeline_args . extend ( [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] ) <EOL> p = df . Pipeline ( argv = pipeline_args ) <EOL> lines = p | df . io . Read ( '<STR_LIT>' , df . io . TextFileSource ( known_args . input ) ) <EOL> counts = ( lines <EOL> | ( df . FlatMap ( '<STR_LIT>' , lambda x : re . findall ( r'<STR_LIT>' , x ) ) <EOL> . with_output_types ( unicode ) ) <EOL> | df . Map ( '<STR_LIT>' , lambda x : ( x , <NUM_LIT:1> ) ) <EOL> | df . GroupByKey ( '<STR_LIT>' ) <EOL> | df . Map ( '<STR_LIT:count>' , lambda ( word , ones ) : ( word , sum ( ones ) ) ) ) <EOL> output = counts | df . Map ( '<STR_LIT>' , lambda ( word , c ) : '<STR_LIT>' % ( word , c ) ) <EOL> output | df . io . Write ( '<STR_LIT>' , df . io . TextFileSink ( known_args . output ) ) <EOL> p . run ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> logging . getLogger ( ) . setLevel ( logging . INFO ) <EOL> run ( ) </s>
