<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from topia.termextract import extract

class TermFinder(object):


    def __init__(self, text):
        self.text = text


    def exctract(self):
        """
            Finds terms in text and returns them as list of tuples
            ( term, term amount, term length in  words)
        """
        extractor = extract.TermExtractor()
        extractor.filter = extract.permissiveFilter
        return extractor(self.text)

if __name__ == "__main__":
    argv=sys.argv
    with open (argv[1], "r") as myfile:
        text=myfile.read().replace('\n', ' ')
    termFinder =  TermFinder(text)
    extracted =  termFinder.exctract()
    print len(extracted)
    print extracted
<commit_msg>changed term_finder.py to file with functions<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from topia.termextract import extract

def exctract(text):
    """
            Finds terms in text and returns them as list of tuples
            ( term, term amount, term length in  words)
    """
    extractor = extract.TermExtractor()
    extractor.filter = extract.permissiveFilter
    return extractor(text)

if __name__ == "__main__":
    argv=sys.argv
    with open (argv[1], "r") as myfile:
        text=myfile.read().replace('\n', ' ')
    extracted =  exctract(text)
    print len(extracted)
    print extracted

{'fraction_non_alphanumeric': 0.11483594864479316, 'fraction_numerical': 0.0028530670470756064, 'mean_word_length': 2.6727748691099475, 'pattern_counts': {'":': 2, '<': 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': '4504891', 'n_tokens_mistral': 429, 'n_tokens_neox': 434, 'n_words': 120}