Commit c1c4245d authored by Łukasz Kopociński's avatar Łukasz Kopociński

Remove old tests

parent 4dc2c82e
('116', '00198000', 'sent1', 0)
('116', '00198000', 'sent1', 1)
('116', '00198000', 'sent1', 2)
('116', '00198000', 'sent1', 3)
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chunkList SYSTEM "ccl.dtd">
<relations>
<rel name="ner relation" set="NER relation">
<from sent="sent8" chan="PRODUCT_NAME">1008479</from>
<to sent="sent8" chan="BRAND_NAME">994201</to>
</rel>
<rel name="ner relation" set="NER relation">
<from sent="sent8" chan="BRAND_NAME">994201</from>
<to sent="sent8" chan="PRODUCT_NAME">1008479</to>
</rel>
<rel name="ner relation" set="NER relation">
<from sent="sent8" chan="BRAND_NAME">994201</from>
<to sent="sent8" chan="PRODUCT_NAME">1008479</to>
</rel>
<rel name="ner relation" set="NER relation">
<from sent="sent8" chan="BRAND_NAME">994201</from>
<to sent="sent8" chan="PRODUCT_NAME">1008479</to>
</rel>
<rel name="ner relation" set="NER relation">
<from sent="sent10" chan="BRAND_NAME">994202</from>
<to sent="sent10" chan="PRODUCT_NAME_IMP">1009405</to>
</rel>
<rel name="ner relation" set="NER relation">
<from sent="sent8" chan="BRAND_NAME">994201</from>
<to sent="sent8" chan="PRODUCT_NAME">1008479</to>
</rel>
<rel name="ner relation" set="NER relation">
<from sent="sent10" chan="BRAND_NAME">994202</from>
<to sent="sent10" chan="PRODUCT_NAME_IMP">1009405</to>
</rel>
</relations>
This diff is collapsed.
import torch
from scripts import MapLoader
KEYS_FILE = './test.map.keys'
VECTORS_FILE = './test.map.pt'
def test_load_map():
expected_keys = {
('116', '00198000', 'sent1', 0): 0,
('116', '00198000', 'sent1', 1): 1,
('116', '00198000', 'sent1', 2): 2,
('116', '00198000', 'sent1', 3): 3
}
expected_vectors = torch.FloatTensor([
[0.1070, -0.1315, -0.1719, -0.1000, 0.0375],
[0.1972, -0.1865, -0.1212, 0.0129, -0.0543],
[0.2795, 0.0798, -0.0098, -0.1617, 0.0672],
[0.2459, 0.0555, -0.0038, -0.3139, -0.3428]
])
map_loader = MapLoader(
keys_file=KEYS_FILE,
vectors_file=VECTORS_FILE
)
keys, vectors = map_loader()
assert keys == expected_keys
assert repr(expected_vectors) == repr(vectors)
from unittest import mock
from unittest.mock import PropertyMock
from scripts import MapMaker
@mock.patch('data.scripts.maps.Document', autospec=True)
@mock.patch('data.scripts.maps.DocSentence', autospec=True)
def test_make_keys(document, sentence):
type(document).directory = PropertyMock(return_value='DIR')
type(document).id = PropertyMock(return_value='DOC_ID')
type(sentence).id = PropertyMock(return_value='SENT_ID')
type(sentence).orths = PropertyMock(
return_value=['orth0', 'orth1', 'orth2']
)
keys = MapMaker.make_keys(document, sentence)
expected_keys = [
('DIR', 'DOC_ID', 'SENT_ID', 0),
('DIR', 'DOC_ID', 'SENT_ID', 1),
('DIR', 'DOC_ID', 'SENT_ID', 2)
]
assert keys == expected_keys
@mock.patch('data.scripts.vectorizers.Vectorizer', autospec=True)
@mock.patch('data.scripts.maps.Document', autospec=True)
@mock.patch.object(
MapMaker, 'make_sentence_map', autospec=True, return_value=[]
)
def test_make_document_map(vectorizer, document):
type(document).sentences = PropertyMock(
return_value=['sent1', 'sent2', 'sent3']
)
maker = MapMaker(vectorizer)
maker.make_document_map(document)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment