<commit_before>#!/usr/bin/env python
"""Mapper to filter and extract types"""

import sys
from kilogram.ngram_service import SUBSTITUTION_TOKEN

for line in sys.stdin:
    # split the line into words
    ngram, num = line.strip().split('\t')

    if int(num) < 100:
        continue

    type_count = ngram.count('<dbpedia:')
    ngram = ngram.split()
    if type_count > 0:
        type_indexes = [i for i, x in enumerate(ngram) if x.startswith('<dbpedia:')]
        for type_index in type_indexes:
            entity_type = ngram[type_index]
            ngram[type_index] = SUBSTITUTION_TOKEN
            new_ngram = " ".join(ngram)
            print '%s\t%s\t%s' % (new_ngram, entity_type, num)<commit_msg>minor<commit_after>#!/usr/bin/env python
"""Mapper to filter and extract types"""

import sys
from kilogram.ngram_service import SUBSTITUTION_TOKEN

for line in sys.stdin:
    # split the line into words
    ngram, num = line.strip().split('\t')

    if int(num) < 10:
        continue

    type_count = ngram.count('<dbpedia:')
    ngram = ngram.split()
    if type_count > 0:
        type_indexes = [i for i, x in enumerate(ngram) if x.startswith('<dbpedia:')]
        for type_index in type_indexes:
            entity_type = ngram[type_index]
            ngram[type_index] = SUBSTITUTION_TOKEN
            new_ngram = " ".join(ngram)
            print '%s\t%s\t%s' % (new_ngram, entity_type, num)
{'fraction_non_alphanumeric': 0.12065294535131299, 'fraction_numerical': 0.0049680624556423, 'mean_word_length': 2.780160857908847, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '1062837', 'n_tokens_mistral': 501, 'n_tokens_neox': 481, 'n_words': 121}