예제 #1
0
def check_parse_sentence(tokenize=False):
    """
    Check parse_sentence method with and without tokenization
    """
    from tests import parser

    sentence = "I'm going to the market." if tokenize else "I 'm going to the market ."
    correct_output = "(S (NP (PRP I)) (VP (VBP 'm) (VP (VBG going) (PP (TO to) (NP (DT the) (NN market))))) (. .))"
    parsed_sentence = parser.parse_sentence(sentence, tokenize=tokenize)

    assert_equal(parsed_sentence, correct_output)
예제 #2
0
def check_parse_sentence(tokenize=False):
    """
    Check parse_sentence method with and without tokenization
    """
    from tests import parser

    sentence = "I'm going to the market." if tokenize else "I 'm going to the market ."
    correct_output = "(S (NP (PRP I)) (VP (VBP 'm) (VP (VBG going) (PP (TO to) (NP (DT the) (NN market))))) (. .))"
    parsed_sentence = parser.parse_sentence(sentence, tokenize=tokenize)

    assert_equal(parsed_sentence, correct_output)
예제 #3
0
def test_zpar_bugfix_parse():
    from tests import parser

    sentences = ['REBELLION',
                 'I am going away .',
                 'The rebellion is just another word for change and change is necessary to live .',
                 'REBELLION',
                 'REBELLION',
                 'The rebellion is just another word for change and change is necessary to live .',
                 'REBELLION',
                 'This is just another sentence .',
                 'REBELLION']

    # tag the above sentences
    parsed_sentences = [parser.parse_sentence(s) for s in sentences]

    # get the parses for all of the all-caps single-word sentences
    # and make sure they are all the same
    indices_to_check = [0, 3, 4, 6, 8]
    parses_to_check = [parsed_sentences[i] for i in indices_to_check]
    assert_equal(set(parses_to_check), {'(NP (NNP REBELLION))'})