<commit_before>from parser_tool import parse, get_parser
from utils import go_over_file

grammar = get_parser("grammars/test_np.fcfg", trace=0)

def test_np_positive():
    def is_ok(sentence):
        trees = parse(grammar, sentence)
        assert len(trees) > 0, "Failed: %s" % sentence
    
    go_over_file("grammars/nounphrase.sample", is_ok)

def test_np_negative():
    """ tests to see if grammar refuses wrong samples """
    
    def is_not_ok(sentence):
        trees = parse(grammar, sentence)
        assert len(trees) == 0, "Failed: %s" % sentence

    go_over_file("grammars/nounphrase.sample.negative", is_not_ok)
<commit_msg>Distinguish between negative and positive failures<commit_after>from parser_tool import parse, get_parser
from utils import go_over_file

grammar = get_parser("grammars/test_np.fcfg", trace=0)

def test_np_positive():
    def is_ok(sentence):
        trees = parse(grammar, sentence)
        assert len(trees) > 0, "Failed Positive: %s" % sentence
    
    go_over_file("grammars/nounphrase.sample", is_ok)

def test_np_negative():
    """ tests to see if grammar refuses wrong samples """
    
    def is_not_ok(sentence):
        trees = parse(grammar, sentence)
        assert len(trees) == 0, "Failed Negative: %s" % sentence

    go_over_file("grammars/nounphrase.sample.negative", is_not_ok)

{'fraction_non_alphanumeric': 0.10887397464578673, 'fraction_numerical': 0.0044742729306487695, 'mean_word_length': 3.9338235294117645, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7344382', 'n_tokens_mistral': 456, 'n_tokens_neox': 434, 'n_words': 107}