<s> import requests <EOL> from copy import deepcopy <EOL> import json <EOL> import time <EOL> import csv <EOL> import sys <EOL> api_key = '<STR_LIT>' <EOL> url_template = '<STR_LIT>' <EOL> if len ( sys . argv ) < <NUM_LIT:2> : <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> filename = sys . argv [ <NUM_LIT:1> ] <EOL> print '<STR_LIT>' % filename <EOL> with open ( filename ) as f : <EOL> content = f . read ( ) <EOL> input_keywords = { <EOL> '<STR_LIT:content>' : content , <EOL> } <EOL> input_outer = { <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT:data>' : None , <EOL> } <EOL> headers = { <EOL> '<STR_LIT>' : api_key , <EOL> } <EOL> input_full = deepcopy ( input_outer ) <EOL> input_full [ '<STR_LIT:data>' ] = input_keywords <EOL> t0 = time . time ( ) <EOL> r = requests . post ( url_template % '<STR_LIT>' , headers = headers , data = json . dumps ( input_full ) ) <EOL> output_full = r . json ( ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as f : <EOL> writer = csv . writer ( f , quoting = csv . QUOTE_NONNUMERIC ) <EOL> for i , k in enumerate ( output_full [ '<STR_LIT:data>' ] [ '<STR_LIT>' ] ) : <EOL> keyword , relevance = k [ '<STR_LIT>' ] , k [ '<STR_LIT>' ] <EOL> writer . writerow ( [ keyword . encode ( '<STR_LIT:utf-8>' ) , relevance ] ) </s>
