Ejemplo n.º 1
0
def test_article_data_must_be_a_list():
    expected='article data must be a list'
    datalist={"title":"","content":"我是内容"}
    # 摘要接口
    myparms = {"percentage": 0.3, "charLimit": 1000}
    m1 = test_summary.send_summary(myparms, datalist)
    assert m1 == expected

    # 情感接口
    myparms = {"domain": "content"}
    m1 = test_sentiment.send_sentiment(myparms, datalist)
    assert m1 == expected

    # 实体接口
    m1 = test_ner.send_ner(datalist)
    assert m1 == expected

    # 分词接口
    m1 = test_splitword.send_splitword(datalist)
    assert m1 == expected

    # 分句接口
    m1 = test_splitsentence.send_sentence(datalist)
    assert m1 == expected

    # 关键表述

    # 词性接口
    m1 = test_postag.send_postag(datalist)
    assert m1 == expected

    # 文本分类接口
    m1 = test_mlableclassifier.send_mlableclassifier(datalist)
    assert m1 == expected
Ejemplo n.º 2
0
def test_content_is_null(datalist):
    expected = 'content is null'

    # 摘要接口
    myparms = {"percentage": 0.3, "charLimit": 1000}
    m1 = test_summary.send_summary(myparms, datalist)
    assert m1.endswith(expected)

    # 情感接口
    myparms = {"domain": "content"}
    m1 = test_sentiment.send_sentiment(myparms, datalist)
    assert m1.endswith(expected)

    # 实体接口
    m1 = test_ner.send_ner(datalist)
    assert m1.endswith(expected)

    # 分词接口
    m1 = test_splitword.send_splitword(datalist)
    assert m1.endswith(expected)

    # 分句接口
    m1 = test_splitsentence.send_sentence(datalist)
    assert m1.endswith(expected)

    # 关键表述

    # 词性接口
    m1 = test_postag.send_postag(datalist)
    assert m1.endswith(expected)

    # 文本分类接口
    m1 = test_mlableclassifier.send_mlableclassifier(datalist)
    assert m1.endswith(expected)
Ejemplo n.º 3
0
def test_no_article_in_data():
    datalist=[]
    expected='no article in data'
    # 摘要接口
    myparms = {"percentage": 0.3, "charLimit": 1000}
    m1 = test_summary.send_summary(myparms, datalist)
    assert m1 == expected

    # 情感接口
    myparms = {"domain": "content"}
    m1 = test_sentiment.send_sentiment(myparms, datalist)
    assert m1 == expected

    # 实体接口
    m1 = test_ner.send_ner(datalist)
    assert m1 == expected

    # 分词接口
    m1 = test_splitword.send_splitword(datalist)
    assert m1 == expected

    # 分句接口
    m1 = test_splitsentence.send_sentence(datalist)
    assert m1 == expected

    # 关键表述

    # 词性接口
    m1 = test_postag.send_postag(datalist)
    assert m1 == expected

    # 文本分类接口
    m1 = test_mlableclassifier.send_mlableclassifier(datalist)
    assert m1 == expected
Ejemplo n.º 4
0
def test_has_no_content():
    expected = 'article 2 has no content'
    datalist = [{"title": "", "content": "我是内容"}, {"title":"","content": "我是第二個内容"},{"title":""}]
    # 摘要接口
    myparms = {"percentage": 0.3, "charLimit": 1000}
    m1 = test_summary.send_summary(myparms, datalist)
    assert m1 == expected

    # 情感接口
    myparms = {"domain": "content"}
    m1 = test_sentiment.send_sentiment(myparms, datalist)
    assert m1 == expected

    # 实体接口
    m1 = test_ner.send_ner(datalist)
    assert m1 == expected

    # 分词接口
    m1 = test_splitword.send_splitword(datalist)
    assert m1 == expected

    # 分句接口
    m1 = test_splitsentence.send_sentence(datalist)
    assert m1 == expected

    # 关键表述

    # 词性接口
    m1 = test_postag.send_postag(datalist)
    assert m1 == expected

    # 文本分类接口
    m1 = test_mlableclassifier.send_mlableclassifier(datalist)
    assert m1 == expected
Ejemplo n.º 5
0
def test_article_is_not_a_dict():
    expected = 'is not a dict'
    datalist = [{"title": "", "content": "我是内容"},("title")]
    # 摘要接口
    myparms = {"percentage": 0.3, "charLimit": 1000}
    m1 = test_summary.send_summary(myparms, datalist)
    assert m1.endswith(expected)

    # 情感接口
    myparms = {"domain": "content"}
    m1 = test_sentiment.send_sentiment(myparms, datalist)
    assert m1.endswith(expected)

    # 实体接口
    m1 = test_ner.send_ner(datalist)
    assert m1.endswith(expected)

    # 分词接口
    m1 = test_splitword.send_splitword(datalist)
    assert m1.endswith(expected)

    # 分句接口
    m1 = test_splitsentence.send_sentence(datalist)
    assert m1.endswith(expected)

    # 关键表述

    # 词性接口
    m1 = test_postag.send_postag(datalist)
    assert m1.endswith(expected)

    # 文本分类接口
    m1 = test_mlableclassifier.send_mlableclassifier(datalist)
    assert m1.endswith(expected)
Ejemplo n.º 6
0
def test_too_many_articles():
    #最多支持1000个文章
    expected='too many articles'
    datalist=[]
    for i in range(1002):
        datalist.append({"title":"","content":"文章详细内容"})

    #摘要接口
    myparms = {"percentage": 0.3, "charLimit": 1000}
    m1=test_summary.send_summary(myparms,datalist)
    assert m1==expected

    #情感接口
    myparms = {"domain": "content"}
    m1=test_sentiment.send_sentiment(myparms,datalist)
    assert m1==expected

    #实体接口
    m1=test_ner.send_ner(datalist)
    assert m1 ==expected

    #分词接口
    m1=test_splitword.send_splitword(datalist)
    assert m1 ==expected

    #分句接口
    m1 = test_splitsentence.send_sentence(datalist)
    assert m1 == expected

    #关键表述


    #词性接口
    m1=test_postag.send_postag(datalist)
    assert m1 ==expected

    #文本分类接口
    m1=test_mlableclassifier.send_mlableclassifier(datalist)
    assert m1 == expected
Ejemplo n.º 7
0
def test_content_is_not_Chinese():
    expected='article 1 content is not Chinese'
    content="Do you want a friend whom you could tell everything to, like your deepest feelings and thoughts? 我的英文Or are you afraid that your friend would laugh at you, or would not understand what you are going through? Anne Frank wanted the first kind, so she made her diary her best friend.Annie lived in Amsterdam in the Netherlands during World War II. Her family was Jewish so they had to hide or they would be caught by the German Nazis. She and her family hid away for nearly twenty-five months before they were discovered. During that time the only true friend was her diary. She said, I don't want to set down a series of facts in a diary as most people do, but I want this diary itself to be my best friend, and I shall call my friend Kitty. Now read how she felt after being in the hiding place since July 1942."
    datalist = [{"title": "", "content": content}]

    # 摘要接口
    myparms = {"percentage": 0.3, "charLimit": 1000}
    m1 = test_summary.send_summary(myparms, datalist)
    assert m1 == expected

    # 情感接口
    myparms = {"domain": "content"}
    m1 = test_sentiment.send_sentiment(myparms, datalist)
    assert m1 == expected

    # 实体接口
    m1 = test_ner.send_ner(datalist)
    assert m1 == expected

    # 分词接口
    m1 = test_splitword.send_splitword(datalist)
    assert m1 == expected

    # 分句接口
    m1 = test_splitsentence.send_sentence(datalist)
    assert m1 == expected

    # 关键表述

    # 词性接口
    m1 = test_postag.send_postag(datalist)
    assert m1 == expected

    # 文本分类接口
    m1 = test_mlableclassifier.send_mlableclassifier(datalist)
    assert m1 == expected
Ejemplo n.º 8
0
def test_title_is_longer_than_100():
    title="布洛芬是我们生活中的常用药,对于布洛芬这个药物,它的功效相对来说是比较多的,可以有效退热、缓解由于感冒流感等引起的轻度头疼、咽痛以及牙痛等症状,但是布洛芬这个药物,并不是适合所有人服用的,哪些人不是個。"
    datalist=[{"title":"","content":"我是内容"},{"title":title,"content":"我是内容"}]
    expected = 'article 1 title is longer than 100'

    # 摘要接口
    myparms = {"percentage": 0.3, "charLimit": 1000}
    m1 = test_summary.send_summary(myparms, datalist)
    assert m1 == expected

    # 情感接口
    myparms = {"domain": "content"}
    m1 = test_sentiment.send_sentiment(myparms, datalist)
    assert m1 == expected

    # 实体接口
    m1 = test_ner.send_ner(datalist)
    assert m1 == expected

    # 分词接口
    m1 = test_splitword.send_splitword(datalist)
    assert m1 == expected

    # 分句接口
    m1 = test_splitsentence.send_sentence(datalist)
    assert m1 == expected

    # 关键表述

    # 词性接口
    m1 = test_postag.send_postag(datalist)
    assert m1 == expected

    # 文本分类接口
    m1 = test_mlableclassifier.send_mlableclassifier(datalist)
    assert m1 == expected