示例#1
0
def test_json_not_vtnstandard():
    vtn = {"objectively": "not a vtn-standard structure"}

    try:
        result = process_json(vtn, "word")
        assert False
    except Exception as e:
        assert 'not a valid vtn-standard transcription' in str(e)
示例#2
0
def test_json():
    vtn = {
        "series": [
            {
                "words": [{
                    "word": "That's pretty good.",
                    "confidence": 0.9,
                }],
            },
        ]
    }

    result = process_json(vtn, "word")

    assert 'series' in result
    assert hasPositiveSentiment(result['series'][0])
示例#3
0
def test_json_everything():
    vtn = {
        "series": [
            {
                "words": [{
                    "word": "That's pretty good.",
                    "confidence": 0.9,
                }],
            },
        ]
    }

    result = process_json(vtn, "sentence,word,document")

    assert 'series' in result
    assert hasPositiveSentiment(result['series'][0])  # has word sentiment
    assert 'object' in result  # has sentence sentiment
    assert 'sentiment' in result  # has document sentiment
示例#4
0
def test_json_sentence():
    vtn = {
        "series": [
            {
                "words": [{
                    "word": "That's pretty good.",
                    "confidence": 0.9,
                }],
            },
        ]
    }

    result = process_json(vtn, "sentence")

    assert 'series' in result
    assert hasNoSentiment(result['series'][0])  # no word sentiment
    assert 'object' in result  # has sentence sentiment
    assert 'sentiment' not in result  # no document sentiment
示例#5
0
def test_json_selects_highest_confidence():
    vtn = {
        "series": [
            {
                "words": [{
                    "word": "That's pretty good.",
                    "confidence": 0.9,
                }, {
                    "word": "That's sucks.",
                    "confidence": 0.97,
                }],
            },
        ]
    }

    result = process_json(vtn, "word")

    assert 'series' in result
    assert hasNegativeSentiment(result['series'][0])
示例#6
0
def test_json_punctuation():
    vtn = {
        "series": [
            {
                "words": [{
                    "word": "Hello"
                }]
            },
            {
                "words": [{
                    "word": "!"
                }]
            },
        ]
    }

    result = process_json(vtn, "word")

    assert 'series' in result
    assert hasZeroSentiment(result['series'][1])