def main():
    args = parse_args()
    warnings.simplefilter('always')
    resolver_kwargs = {}
    if args.order is not None:
        resolver_kwargs['order'] = args.order.split(',')
    if args.options is not None:
        resolver_kwargs['options'] = json.loads(args.options)
    resolver = get_resolver(**resolver_kwargs)
    resolver.load_locations(location_file=args.location_file)
    # Variables for statistics.
    city_found = county_found = state_found = country_found = 0
    has_place = has_coordinates = has_geo = has_profile_location = 0
    resolution_method_counts = collections.defaultdict(int)
    skipped_tweets = resolved_tweets = total_tweets = 0
    for i, input_line in enumerate(args.input_file):
        # Show warnings from the input file, not the Python source code.
        def showwarning(message, category, filename, lineno,
                        file=sys.stderr, line=None):
            sys.stderr.write(warnings.formatwarning(
                message, category, args.input_file.name, i+1,
                line=''))
        warnings.showwarning = showwarning
        try:
            tweet = json.loads(input_line)
        except __HOLE__:
            warnings.warn('Invalid JSON object')
            skipped_tweets += 1
            continue
        # Collect statistics on the tweet.
        if tweet.get('place'):
            has_place += 1
        if tweet.get('coordinates'):
            has_coordinates += 1
        if tweet.get('geo'):
            has_geo += 1
        if tweet.get('user', {}).get('location', ''):
            has_profile_location += 1
        # Perform the actual resolution.
        resolution = resolver.resolve_tweet(tweet)
        if resolution:
            location = resolution[1]
            tweet['location'] = location
            # More statistics.
            resolution_method_counts[location.resolution_method] += 1
            if location.city:
                city_found += 1
            elif location.county:
                county_found += 1
            elif location.state:
                state_found += 1
            elif location.country:
                country_found += 1
            resolved_tweets += 1
        print >> args.output_file, json.dumps(tweet, cls=LocationEncoder)
        total_tweets += 1
    if args.statistics:
        print >> sys.stderr, 'Skipped %d tweets.' % skipped_tweets
        print >> sys.stderr, ('Tweets with "place" key: %d; '
                              '"coordinates" key: %d; '
                              '"geo" key: %d.' % (
                                has_place, has_coordinates, has_geo))
        print >> sys.stderr, ('Resolved %d tweets to a city, '
                              '%d to a county, %d to a state, '
                              'and %d to a country.' % (
                                city_found, county_found,
                                state_found, country_found))
        print >> sys.stderr, ('Tweet resolution methods: %s.' % (
            ', '.join('%d by %s' % (v, k)
                for (k, v) in resolution_method_counts.iteritems())))
    print >> sys.stderr, 'Resolved locations for %d of %d tweets.' % (
        resolved_tweets, total_tweets)
dataset/ETHPy150Open Kitware/minerva/server/libs/carmen/cli.py/main