<commit_before>
import copy
import json
import click
from maxrect import get_maximal_rectangle, rect2poly


@click.command('maxrect')
@click.argument('polygon', default='-', required=False)
@click.option('--compare', is_flag=True, help='Leaves the original polygon in the feature collection')
@click.pass_context
def cli(ctx, polygon, compare):
    """
    Get an approximately maximal area, axis-aligned rectangle
    for a polygon represented by GeoJSON.
    """

    if polygon == '-':
        src = click.open_file('-')

        if not src.isatty():
            data = src.read()
        else:
            click.echo(ctx.get_usage())
            ctx.exit(1)
    else:
        with open(polygon, 'r') as src:
            data = src.read()

    geojson = json.loads(data)
<commit_msg>support feature and feature collections<commit_after>
import copy
import json
import click
from maxrect import get_maximal_rectangle, rect2poly


@click.command('maxrect')
@click.argument('polygon', default='-', required=False)
@click.option('--compare', is_flag=True, help='Leaves the original polygon in the feature collection')
@click.pass_context
def cli(ctx, polygon, compare):
    """
    Get an approximately maximal area, axis-aligned rectangle
    for a polygon represented by GeoJSON.
    """

    if polygon == '-':
        src = click.open_file('-')

        if not src.isatty():
            data = src.read()
        else:
            click.echo(ctx.get_usage())
            ctx.exit(1)
    else:
        with open(polygon, 'r') as src:
            data = src.read()

    geojson = json.loads(data)

    if geojson.get('type') == 'Feature':

        geojson = {
            'type': 'FeatureCollection',
            'features': [geojson]
        }

{'fraction_non_alphanumeric': 0.12714776632302405, 'fraction_numerical': 0.002290950744558992, 'mean_word_length': 2.6701680672268906, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4402862', 'n_tokens_mistral': 534, 'n_tokens_neox': 511, 'n_words': 144}