nouns_pps.py
def compound_stats(entries):
    "Count the total number of compounds in the data, and their lengths"
    print('Compounds')
    data = dict()
    data['compound_lengths'] = Counter()
    data['compound_counts']  = Counter()
    data['counts_by_length'] = defaultdict(Counter)
    data['total_compounds'] = 0
    for entry in entries:
        for compound in entry['compounds']:
            length = len(compound)
            compound_string = ' '.join(compound)
            # Count everything
            data['compound_lengths'][length] += 1
            data['compound_counts'][compound_string] += 1
            data['counts_by_length'][length][compound_string] += 1
            data['total_compounds'] += 1
    data['compound_ratio'] = data['total_compounds']/ len(entries)
    return data
Count the total number of compounds in the data, and their lengths
Count the total number of compounds in the data, and their lengths
Count the total number of compounds in the data and their lengths
def compound_stats(entries):
    print('Compounds')
    data = dict()
    data['compound_lengths'] = Counter()
    data['compound_counts']  = Counter()
    data['counts_by_length'] = defaultdict(Counter)
    data['total_compounds'] = 0
    for entry in entries:
        for compound in entry['compounds']:
            length = len(compound)
            compound_string = ' '.join(compound)
            data['compound_lengths'][length] += 1
            data['compound_counts'][compound_string] += 1
            data['counts_by_length'][length][compound_string] += 1
            data['total_compounds'] += 1
    data['compound_ratio'] = data['total_compounds']/ len(entries)
    return data
def compound_stats ( entries ) : print ( 'Compounds' ) data = dict ( ) data [ 'compound_lengths' ] = Counter ( ) data [ 'compound_counts' ] = Counter ( ) data [ 'counts_by_length' ] = defaultdict ( Counter ) data [ 'total_compounds' ] = 0 for entry in entries : for compound in entry [ 'compounds' ] : length = len ( compound ) compound_string = ' ' . join ( compound ) data [ 'compound_lengths' ] [ length ] += 1 data [ 'compound_counts' ] [ compound_string ] += 1 data [ 'counts_by_length' ] [ length ] [ compound_string ] += 1 data [ 'total_compounds' ] += 1 data [ 'compound_ratio' ] = data [ 'total_compounds' ] / len ( entries ) return data
Count the total number of compounds in the data, and their lengths
Count the total number of compounds in the data and their lengths
"Count the total number of compounds in the data, and their lengths" # Count everything
entries