<commit_before>"""
Speech Rule Decorator Module
Need to add docstring
"""
import logging
from .rules import RuleMap

from parse import parse

class Parser(object):
    """
    Speech Rule Decorator class
    Accepts an optional audio source input from the speech_recognition module
    """

    def __init__(self):
        """Initalizer"""
        self.debug = False
        self._rule_map = RuleMap(list)


    def on_recognize(self, eventname):
        """Decorator for rules. Calls the associated functions when the rule is invoked via voice"""
        def eventdecorator(func):
            """Event decorator closure thing"""
            self._func_registry.add_rule(eventname, func)
            return func
        return eventdecorator


    def parse_file(self, file):
        with open(file, 'r') as f:
            for line in f:
                self._rule_map.query(line)<commit_msg>changed docstrings to reflect new code refactor<commit_after>"""
parser.py
This contains the main Parser class that can be instantiated to create rules.
"""
import logging
from .rules import RuleMap

from parse import parse

class Parser(object):
    """
    Parser exposes a couple methods for reading in strings.
    Currently only parse_file is working.
    """

    def __init__(self):
        """Initalizer"""
        self.debug = False
        self._rule_map = RuleMap(list)


    def on_recognize(self, eventname):
        """Decorator for rules. Calls the associated functions when the rule is invoked via voice"""
        def eventdecorator(func):
            """Event decorator closure thing"""
            self._func_registry.add_rule(eventname, func)
            return func
        return eventdecorator


    def parse_file(self, file):
        with open(file, 'r') as f:
            for line in f:
                self._rule_map.query(line)
{'fraction_non_alphanumeric': 0.08229561451001624, 'fraction_numerical': 0.0, 'mean_word_length': 2.560693641618497, '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': '3046322', 'n_tokens_mistral': 504, 'n_tokens_neox': 487, 'n_words': 179}