Browse Source

add testing codes and data for loader and pipe.

tags/v0.4.10
Yige Xu 5 years ago
parent
commit
b9aa05f6cf
17 changed files with 102 additions and 6 deletions
  1. +2
    -0
      test/data_for_tests/io/cws_msra/dev.txt
  2. +2
    -0
      test/data_for_tests/io/cws_msra/test.txt
  3. +3
    -0
      test/data_for_tests/io/cws_msra/train.txt
  4. +2
    -0
      test/data_for_tests/io/imdb/dev.txt
  5. +2
    -0
      test/data_for_tests/io/imdb/test.txt
  6. +2
    -0
      test/data_for_tests/io/imdb/train.txt
  7. +3
    -0
      test/data_for_tests/io/rte/dev.tsv
  8. +3
    -0
      test/data_for_tests/io/rte/test.tsv
  9. +4
    -0
      test/data_for_tests/io/rte/train.tsv
  10. +8
    -0
      test/io/loader/test_classification_loader.py
  11. +12
    -2
      test/io/loader/test_conll_loader.py
  12. +12
    -1
      test/io/loader/test_cws_loader.py
  13. +8
    -0
      test/io/loader/test_matching_loader.py
  14. +8
    -0
      test/io/pipe/test_classification.py
  15. +12
    -2
      test/io/pipe/test_conll.py
  16. +11
    -1
      test/io/pipe/test_cws.py
  17. +8
    -0
      test/io/pipe/test_matching.py

+ 2
- 0
test/data_for_tests/io/cws_msra/dev.txt View File

@@ -0,0 +1,2 @@
“ 人们 常 说 生活 是 一 部 教科书 , 而 血 与 火 的 战争 更 是 不可多得 的 教科书 , 她 确实 是 名副其实 的 ‘ 我 的 大学 ’ 。
他 “ 严格要求 自己 , 从 一个 科举 出身 的 进士 成为 一个 伟大 的 民主主义 者 , 进而 成为 一 位 杰出 的 党外 共产主义 战士 , 献身 于 崇高 的 共产主义 事业 。

+ 2
- 0
test/data_for_tests/io/cws_msra/test.txt View File

@@ -0,0 +1,2 @@
扬帆 远东 做 与 中国 合作 的 先行
希腊 的 经济 结构 较 特殊 。

+ 3
- 0
test/data_for_tests/io/cws_msra/train.txt View File

@@ -0,0 +1,3 @@
“ 心 静 渐 知 春 似 海 , 花 深 每 觉 影 生 香 。
“ 吃 屎 的 东西 , 连 一 捆 麦 也 铡 不 动 呀 ?
复旦大学 百年 校庆 。

+ 2
- 0
test/data_for_tests/io/imdb/dev.txt View File

@@ -0,0 +1,2 @@
neg It, at all, you have seen when harry met sally, then avoid this one. It will not only make you bang your head on the table as why can't bollywood even make a good remake; but also annoy you with the so called funny moments in it. The charm of the movie is missing. Ranee looks terrible. Saif tries to act like he is one hell of an actor. The plots that have been picked up from the original, don't look effective either. The part where both of them bring their friends along and they hit a note, it just doesn't look appealing. What can be more disastrous? you wanna waste some money, this is what you can get. Otherwise, put some more bucks, and watch the original. Its too good to miss..
neg The monster from Enemy Mine somehow made his way into a small mountain community, where he has taken up residence. He's being hunted by a female doctor-turned-vigilante who is out to exterminate him. This female assassin, who looks like a refugee from a Motley Crue video, rides around on a motorcycle and tries to save a bunch of kids who have chosen to have a Big Chill weekend right smack dab in the middle of the monster's turf. Decapitations and lots of blood are primarily in place to draw attention away from the story which limps along like a bad version of the Island of Dr. Moreau (and yes, it's worse than the one with Val Kilmer).

+ 2
- 0
test/data_for_tests/io/imdb/test.txt View File

@@ -0,0 +1,2 @@
neg Alan Rickman & Emma Thompson give good performances with southern/New Orleans accents in this detective flick. It's worth seeing for their scenes- and Rickman's scene with Hal Holbrook. These three actors mannage to entertain us no matter what the movie, it seems. The plot for the movie shows potential, but one gets the impression in watching the film that it was not pulled off as well as it could have been. The fact that it is cluttered by a rather uninteresting subplot and mostly uninteresting kidnappers really muddles things. The movie is worth a view- if for nothing more than entertaining performances by Rickman, Thompson, and Holbrook.
neg I have seen this movie and I did not care for this movie anyhow. I would not think about going to Paris because I do not like this country and its national capital. I do not like to learn french anyhow because I do not understand their language. Why would I go to France when I rather go to Germany or the United Kingdom? Germany and the United Kingdom are the nations I tolerate. Apparently the Olsen Twins do not understand the French language just like me. Therefore I will not bother the France trip no matter what. I might as well stick to the United Kingdom and meet single women and play video games if there is a video arcade. That is all.

+ 2
- 0
test/data_for_tests/io/imdb/train.txt View File

@@ -0,0 +1,2 @@
neg I'll try to use words to describe this on.... <br /><br />I saw the original, which was good in its own way, but back then I should have feared a sequel.<br /><br />And I was 'afraid' when I picked this one up, but now that I've seen it, I have to say, it's even worse then I thought. Why these movies still get money still makes my mind spin. <br /><br />Let's start with the actors;they aren't all that good, but it has to be said, some make heads turn by being just plain awful. But what can an actor do with a script like this one. It's trying to be a copy of the original only this time the places have changed, any form of story is gone and any attempt of actually coming up with something that hasn't been done before, fails miserably. In a futile attempt to get it up-to-date, they try to make it exciting by making use of the whole 'big-brother' theme , but that has been worn out ages ago and offers nothing but a filler for between the beginning and the end. An attempt was made to try to save the movie by making a ton of references to the '83 original, but it just ended up being plain funny and sometimes a bit sad. In conclusion, if you have nothing , and I mean nothing , to do... go watch it, or play Frisbee... with the DVD.... by yourself. It'll offer you the same amount of fun.. I promise
pos This movie is totally wicked! It's really great to see MJH in a different role than her Sabrina character! The plot is totally cool, and the characters are excellently written. Definitely one of the best movies!!

+ 3
- 0
test/data_for_tests/io/rte/dev.tsv View File

@@ -0,0 +1,3 @@
index sentence1 sentence2 label
0 Dana Reeve, the widow of the actor Christopher Reeve, has died of lung cancer at age 44, according to the Christopher Reeve Foundation. Christopher Reeve had an accident. not_entailment
1 Yet, we now are discovering that antibiotics are losing their effectiveness against illness. Disease-causing bacteria are mutating faster than we can come up with new antibiotics to fight the new variations. Bacteria is winning the war against antibiotics. entailment

+ 3
- 0
test/data_for_tests/io/rte/test.tsv View File

@@ -0,0 +1,3 @@
index sentence1 sentence2
0 Mangla was summoned after Madhumita's sister Nidhi Shukla, who was the first witness in the case. Shukla is related to Mangla.
1 Authorities in Brazil say that more than 200 people are being held hostage in a prison in the country's remote, Amazonian-jungle state of Rondonia. Authorities in Brazil hold 200 people as hostage.

+ 4
- 0
test/data_for_tests/io/rte/train.tsv View File

@@ -0,0 +1,4 @@
index sentence1 sentence2 label
0 No Weapons of Mass Destruction Found in Iraq Yet. Weapons of Mass Destruction Found in Iraq. not_entailment
1 A place of sorrow, after Pope John Paul II died, became a place of celebration, as Roman Catholic faithful gathered in downtown Chicago to mark the installation of new Pope Benedict XVI. Pope Benedict XVI is the new leader of the Roman Catholic Church. entailment
2 Herceptin was already approved to treat the sickest breast cancer patients, and the company said, Monday, it will discuss with federal regulators the possibility of prescribing the drug for more breast cancer patients. Herceptin can be used to treat breast cancer. entailment

+ 8
- 0
test/io/loader/test_classification_loader.py View File

@@ -17,3 +17,11 @@ class TestDownload(unittest.TestCase):
for loader in [YelpFullLoader, YelpPolarityLoader, IMDBLoader, SST2Loader, SSTLoader]:
data_bundle = loader().load()
print(data_bundle)


class TestLoad(unittest.TestCase):

def test_load(self):
for loader in [IMDBLoader]:
data_bundle = loader().load('test/data_for_tests/io/imdb')
print(data_bundle)

+ 12
- 2
test/io/loader/test_conll_loader.py View File

@@ -1,7 +1,9 @@

import unittest
import os
from fastNLP.io.loader.conll import MsraNERLoader, PeopleDailyNERLoader, WeiboNERLoader
from fastNLP.io.loader.conll import MsraNERLoader, PeopleDailyNERLoader, WeiboNERLoader, \
Conll2003Loader


class MSRANERTest(unittest.TestCase):
@unittest.skipIf('TRAVIS' in os.environ, "Skip in travis")
@@ -10,12 +12,20 @@ class MSRANERTest(unittest.TestCase):
data_bundle = MsraNERLoader().load()
print(data_bundle)


class PeopleDailyTest(unittest.TestCase):
@unittest.skipIf('TRAVIS' in os.environ, "Skip in travis")
def test_download(self):
PeopleDailyNERLoader().download()


class WeiboNERTest(unittest.TestCase):
@unittest.skipIf('TRAVIS' in os.environ, "Skip in travis")
def test_download(self):
WeiboNERLoader().download()
WeiboNERLoader().download()


class TestConll2003Loader(unittest.TestCase):
def test__load(self):
Conll2003Loader()._load('test/data_for_tests/conll_2003_example.txt')


+ 12
- 1
test/io/loader/test_cws_loader.py View File

@@ -10,4 +10,15 @@ class CWSLoaderTest(unittest.TestCase):
for dataset_name in dataset_names:
with self.subTest(dataset_name=dataset_name):
data_bundle = CWSLoader(dataset_name=dataset_name).load()
print(data_bundle)
print(data_bundle)


class RunCWSLoaderTest(unittest.TestCase):
def test_cws_loader(self):
dataset_names = ['msra']
for dataset_name in dataset_names:
with self.subTest(dataset_name=dataset_name):
data_bundle = CWSLoader(dataset_name=dataset_name).load(
f'test/data_for_tests/io/cws_{dataset_name}'
)
print(data_bundle)

+ 8
- 0
test/io/loader/test_matching_loader.py View File

@@ -20,3 +20,11 @@ class TestDownload(unittest.TestCase):
data_bundle = loader().load()
print(data_bundle)


class TestLoad(unittest.TestCase):

def test_load(self):
for loader in [RTELoader]:
data_bundle = loader().load('test/data_for_tests/io/rte')
print(data_bundle)


+ 8
- 0
test/io/pipe/test_classification.py View File

@@ -11,3 +11,11 @@ class TestPipe(unittest.TestCase):
print(pipe)
data_bundle = pipe(tokenizer='raw').process_from_file()
print(data_bundle)


class TestRunPipe(unittest.TestCase):

def test_load(self):
for pipe in [IMDBPipe]:
data_bundle = pipe(tokenizer='raw').process_from_file('test/data_for_tests/io/imdb')
print(data_bundle)

+ 12
- 2
test/io/pipe/test_conll.py View File

@@ -1,6 +1,7 @@
import unittest
import os
from fastNLP.io import MsraNERPipe, PeopleDailyPipe, WeiboNERPipe
from fastNLP.io import MsraNERPipe, PeopleDailyPipe, WeiboNERPipe, Conll2003Pipe, Conll2003NERPipe


@unittest.skipIf('TRAVIS' in os.environ, "Skip in travis")
class TestPipe(unittest.TestCase):
@@ -9,4 +10,13 @@ class TestPipe(unittest.TestCase):
with self.subTest(pipe=pipe):
print(pipe)
data_bundle = pipe().process_from_file()
print(data_bundle)
print(data_bundle)


class TestRunPipe(unittest.TestCase):
def test_conll2003(self):
for pipe in [Conll2003Pipe, Conll2003NERPipe]:
with self.subTest(pipe=pipe):
print(pipe)
data_bundle = pipe().process_from_file('test/data_for_tests/conll_2003_example.txt')
print(data_bundle)

+ 11
- 1
test/io/pipe/test_cws.py View File

@@ -3,6 +3,7 @@ import unittest
import os
from fastNLP.io.pipe.cws import CWSPipe


class CWSPipeTest(unittest.TestCase):
@unittest.skipIf('TRAVIS' in os.environ, "Skip in travis")
def test_process_from_file(self):
@@ -10,4 +11,13 @@ class CWSPipeTest(unittest.TestCase):
for dataset_name in dataset_names:
with self.subTest(dataset_name=dataset_name):
data_bundle = CWSPipe(dataset_name=dataset_name).process_from_file()
print(data_bundle)
print(data_bundle)


class RunCWSPipeTest(unittest.TestCase):
def test_process_from_file(self):
dataset_names = ['msra']
for dataset_name in dataset_names:
with self.subTest(dataset_name=dataset_name):
data_bundle = CWSPipe().process_from_file(f'test/data_for_tests/io/cws_{dataset_name}')
print(data_bundle)

+ 8
- 0
test/io/pipe/test_matching.py View File

@@ -24,3 +24,11 @@ class TestBertPipe(unittest.TestCase):
print(pipe)
data_bundle = pipe(tokenizer='raw').process_from_file()
print(data_bundle)


class TestRunPipe(unittest.TestCase):

def test_load(self):
for pipe in [RTEPipe, RTEBertPipe]:
data_bundle = pipe(tokenizer='raw').process_from_file('test/data_for_tests/io/rte')
print(data_bundle)

Loading…
Cancel
Save