Skip to content
Snippets Groups Projects
Commit 7c9be063 authored by Paweł Walkowiak's avatar Paweł Walkowiak
Browse files

Merge branch 'tests' into 'master'

Tests

See merge request !3
parents bcbb2700 4bc65e51
Branches
1 merge request!3Tests
Pipeline #8140 passed with stages
in 1 minute and 15 seconds
Showing with 103 additions and 26 deletions
{
"postagger_lone_json": {"task": [{"postagger": {"lang": "pl", "output": "json", "json_text": false}}], "input": "post_postagger_input", "expected": "post_postagger_input.json"},
"pre_winer": {"task": [{"postagger": {"lang": "pl", "output": "json"}}, "winer"], "input": "post_postagger_input", "expected": "pre_winer.json"},
"pre_fextor3": {"task": ["any2txt", {"postagger": {"lang": "pl", "output": "json"}}, "fextor3"], "input": "pre_fextor3_input", "expected": "pre_fextor3_expected.json"},
"post_any2txt": {"task": ["any2txt", {"postagger": {"lang": "en", "output": "json"}}], "input": "post_spacy_input", "expected": "post_spacy_expected.json"},
"postagger_lone_lemmas": {"task": [{"postagger": {"lang": "pl", "output": "lemmas"}}], "input": "post_postagger_input", "expected": "post_postagger_input_lemmas"}
}
......@@ -131,7 +131,8 @@ class TaggerWorker(nlp_ws.NLPWorker):
_log
)
# remove tmp directory
shutil.rmtree(destination_path)
if os.path.exists(destination_path):
shutil.rmtree(destination_path)
except Exception as e:
if os.path.exists(destination_path):
shutil.rmtree(destination_path)
......
......@@ -105,8 +105,9 @@ def split_corpus(source_path: str, destination_path: str, file_name: str,
return None
if chunk_size >= file_size:
logging.error('Chunk size is greater than/equal to file size!')
return None
logging.info('Chunk size is greater than/equal to '
'file size, no splitting')
return [source_path]
logging.debug(f'Creating the tree... ({destination_path})')
Path(destination_path).mkdir(parents=True, exist_ok=True)
......
......@@ -29,6 +29,11 @@ def input_file1():
return 'post_spacy_input'
@pytest.fixture
def input_file_small():
return 'post_spacy_small_limit_input'
@pytest.fixture
def input_dir2():
return 'input_dir2'
......@@ -39,6 +44,11 @@ def config(input_dir):
return {'tool': {'config': join(input_dir, 'pos_tagger.yaml')}}
@pytest.fixture
def config_small(input_dir):
return {'tool': {'config': join(input_dir, 'pos_tagger.yaml'), 'chunking_limit': 50}}
@pytest.fixture
def worker(config):
worker = TaggerWorker()
......@@ -46,3 +56,8 @@ def worker(config):
return worker
@pytest.fixture
def worker_small(config_small):
worker = TaggerWorker()
worker.static_init(config_small)
return worker
......@@ -22,20 +22,39 @@ def test_init():
assert type(worker).__name__ == 'TaggerWorker'
# def test_base_process_file(mocker, worker, input_dir, input_file1,
# output_dir, expected_dir):
# mocker.patch('nlp_ws._subtask.SubTask.run', return_value=None)
# mocker.patch('nlp_ws._subtask.SubTask.get_output_path', get_output_path)
# mocker.patch('nlp_ws._subtask.SubTask.prepare_subtask', prepare_subtask)
# mocker.patch('nlp_ws._worker.NLPWorker.update_progress')
# SubTask.prepare_subtask(
# {"q_in": ap.AioQueue(), "q_out": ap.AioQueue()},
# os.getpid()
# )
# worker.process(
# os.path.join(input_dir, input_file1),
# {}, os.path.join(output_dir, input_file1)
# )
# assert cmp(os.path.join(output_dir, input_file1),
# os.path.join(expected_dir, input_file1))
# os.remove(os.path.join(output_dir, input_file1))
def test_base_process_file(mocker, worker, input_dir, input_file1,
output_dir, expected_dir):
mocker.patch('nlp_ws._subtask.SubTask.run', return_value=None)
mocker.patch('nlp_ws._subtask.SubTask.get_output_path', get_output_path)
mocker.patch('nlp_ws._subtask.SubTask.prepare_subtask', prepare_subtask)
mocker.patch('nlp_ws._worker.NLPWorker.update_progress')
SubTask.prepare_subtask(
{"q_in": ap.AioQueue(), "q_out": ap.AioQueue()},
os.getpid()
)
worker.process(
os.path.join(input_dir, input_file1),
{}, os.path.join(output_dir, input_file1)
)
assert cmp(os.path.join(output_dir, input_file1),
os.path.join(expected_dir, input_file1))
os.remove(os.path.join(output_dir, input_file1))
def test_base_process_file_small_limit(mocker, worker_small, input_dir, input_file_small,
output_dir, expected_dir):
mocker.patch('nlp_ws._subtask.SubTask.run', return_value=None)
mocker.patch('nlp_ws._subtask.SubTask.get_output_path', get_output_path)
mocker.patch('nlp_ws._subtask.SubTask.prepare_subtask', prepare_subtask)
mocker.patch('nlp_ws._worker.NLPWorker.update_progress')
SubTask.prepare_subtask(
{"q_in": ap.AioQueue(), "q_out": ap.AioQueue()},
os.getpid()
)
worker_small.process(
os.path.join(input_dir, input_file_small),
{}, os.path.join(output_dir, input_file_small)
)
assert cmp(os.path.join(output_dir, input_file_small),
os.path.join(expected_dir, input_file_small))
os.remove(os.path.join(output_dir, input_file_small))
This diff is collapsed.
woda być jeden z pospolity substancja w wszechświat .
cząsteczka woda być trzeci bardzo rozpowszechniony molekuła w ośrodek międzygwiazdowy , po cząsteczkowy wodór i tlenek węgiel .
być również szeroko rozpowszechniony w Układ Słoneczny : stanowić istotny element budowa ceres i księżyc lodowy krążyć wokół planeta - olbrzym , jako domieszka występować w on atmosfera , a przypuszczać się , że duży on ilość znajdować się w wnętrze ten planeta .
jako lód występować także na część planetoida , a zapewne również na obiekt transneptunowych .
woda być bardzo rozpowszechniony także na powierzchnia Ziemia .
występować głównie w ocean , który pokrywać 70 , 8 % powierzchnia glob , ale także w rzeka , jezioro i w postać stały w lodowiec .
część woda znajdować się w atmosfera ( chmura , para wodny ) .
niektóry związek chemiczny zawierać cząsteczka woda w swój budowa ( hydrat – określać się on wówczas miano woda krystalizacyjny ) .
zawartość woda włączyć w struktura minerał w płaszcz Ziemia móc przekraczać łączny zawartość woda w ocean i inny zbiornik powierzchniowy nawet dziesięciokrotnie .
woda występować w przyroda być roztwór sól i gaz .
najwięcej sól mineralny zawierać woda morski i woda mineralny ; najmniej woda z opad atmosferyczny .
woda o mały zawartość składnik mineralny nazywać woda miękki , natomiast zawierać znaczny ilość sól wapń i magnez – woda twardy .
oprócz to woda naturalny zawierać rozpuścić substancja pochodzenie organiczny , na przykład . mocznik , kwas humusowy i tym podobne .
{"filename": "45b8d169-fc50-4a49-88ee-9327de089183", "tagset": "ud", "tokens": [{"index": 1, "position": [0, 4], "orth": "When", "lexemes": [{"lemma": "when", "mstag": "SCONJ", "disamb": true}]}, {"index": 2, "position": [5, 14], "orth": "Sebastian", "lexemes": [{"lemma": "Sebastian", "mstag": "PROPN", "disamb": true}]}, {"index": 3, "position": [15, 20], "orth": "Thrun", "lexemes": [{"lemma": "Thrun", "mstag": "PROPN", "disamb": true}]}, {"index": 4, "position": [21, 28], "orth": "started", "lexemes": [{"lemma": "start", "mstag": "VERB", "disamb": true}]}, {"index": 5, "position": [29, 36], "orth": "working", "lexemes": [{"lemma": "work", "mstag": "VERB", "disamb": true}]}, {"index": 6, "position": [37, 39], "orth": "on", "lexemes": [{"lemma": "on", "mstag": "ADP", "disamb": true}]}, {"index": 7, "position": [40, 44], "orth": "self", "lexemes": [{"lemma": "self", "mstag": "NOUN", "disamb": true}]}, {"index": 8, "position": [45, 45], "orth": "-", "lexemes": [{"lemma": "-", "mstag": "PUNCT", "disamb": true}]}, {"index": 9, "position": [46, 52], "orth": "driving", "lexemes": [{"lemma": "drive", "mstag": "VERB", "disamb": true}]}, {"index": 10, "position": [53, 57], "orth": "cars", "lexemes": [{"lemma": "car", "mstag": "NOUN", "disamb": true}]}, {"index": 11, "position": [58, 60], "orth": "at", "lexemes": [{"lemma": "at", "mstag": "ADP", "disamb": true}]}, {"index": 12, "position": [61, 67], "orth": "Google", "lexemes": [{"lemma": "Google", "mstag": "PROPN", "disamb": true}]}, {"index": 13, "position": [68, 70], "orth": "in", "lexemes": [{"lemma": "in", "mstag": "ADP", "disamb": true}]}, {"index": 14, "position": [71, 75], "orth": "2007", "lexemes": [{"lemma": "2007", "mstag": "NUM", "disamb": true}]}, {"index": 15, "position": [76, 76], "orth": ",", "lexemes": [{"lemma": ",", "mstag": "PUNCT", "disamb": true}]}, {"index": 16, "position": [77, 80], "orth": "few", "lexemes": [{"lemma": "few", "mstag": "ADJ", "disamb": true}]}, {"index": 17, "position": [81, 87], "orth": "people", "lexemes": [{"lemma": "people", "mstag": "NOUN", "disamb": true}]}, {"index": 18, "position": [88, 95], "orth": "outside", "lexemes": [{"lemma": "outside", "mstag": "ADV", "disamb": true}]}, {"index": 19, "position": [96, 98], "orth": "of", "lexemes": [{"lemma": "of", "mstag": "ADP", "disamb": true}]}, {"index": 20, "position": [99, 102], "orth": "the", "lexemes": [{"lemma": "the", "mstag": "DET", "disamb": true}]}, {"index": 21, "position": [103, 110], "orth": "company", "lexemes": [{"lemma": "company", "mstag": "NOUN", "disamb": true}]}, {"index": 22, "position": [111, 115], "orth": "took", "lexemes": [{"lemma": "take", "mstag": "VERB", "disamb": true}]}, {"index": 23, "position": [116, 119], "orth": "him", "lexemes": [{"lemma": "he", "mstag": "PRON", "disamb": true}]}, {"index": 24, "position": [120, 129], "orth": "seriously", "lexemes": [{"lemma": "seriously", "mstag": "ADV", "disamb": true}]}, {"index": 25, "position": [130, 130], "orth": ".", "lexemes": [{"lemma": ".", "mstag": "PUNCT", "disamb": true}]}, {"index": 26, "position": [131, 132], "orth": "“", "lexemes": [{"lemma": "\"", "mstag": "PUNCT", "disamb": true}]}, {"index": 27, "position": [133, 133], "orth": "I", "lexemes": [{"lemma": "I", "mstag": "PRON", "disamb": true}]}, {"index": 28, "position": [134, 137], "orth": "can", "lexemes": [{"lemma": "can", "mstag": "AUX", "disamb": true}]}, {"index": 29, "position": [138, 142], "orth": "tell", "lexemes": [{"lemma": "tell", "mstag": "VERB", "disamb": true}]}, {"index": 30, "position": [143, 146], "orth": "you", "lexemes": [{"lemma": "you", "mstag": "PRON", "disamb": true}]}, {"index": 31, "position": [147, 151], "orth": "very", "lexemes": [{"lemma": "very", "mstag": "ADV", "disamb": true}]}, {"index": 32, "position": [152, 158], "orth": "senior", "lexemes": [{"lemma": "senior", "mstag": "ADJ", "disamb": true}]}, {"index": 33, "position": [159, 163], "orth": "CEOs", "lexemes": [{"lemma": "ceo", "mstag": "NOUN", "disamb": true}]}, {"index": 34, "position": [164, 166], "orth": "of", "lexemes": [{"lemma": "of", "mstag": "ADP", "disamb": true}]}, {"index": 35, "position": [167, 172], "orth": "major", "lexemes": [{"lemma": "major", "mstag": "ADJ", "disamb": true}]}, {"index": 36, "position": [173, 181], "orth": "American", "lexemes": [{"lemma": "american", "mstag": "ADJ", "disamb": true}]}, {"index": 37, "position": [182, 185], "orth": "car", "lexemes": [{"lemma": "car", "mstag": "NOUN", "disamb": true}]}, {"index": 38, "position": [186, 195], "orth": "companies", "lexemes": [{"lemma": "company", "mstag": "NOUN", "disamb": true}]}, {"index": 39, "position": [196, 201], "orth": "would", "lexemes": [{"lemma": "would", "mstag": "AUX", "disamb": true}]}, {"index": 40, "position": [202, 207], "orth": "shake", "lexemes": [{"lemma": "shake", "mstag": "VERB", "disamb": true}]}, {"index": 41, "position": [208, 210], "orth": "my", "lexemes": [{"lemma": "my", "mstag": "PRON", "disamb": true}]}, {"index": 42, "position": [211, 215], "orth": "hand", "lexemes": [{"lemma": "hand", "mstag": "NOUN", "disamb": true}]}, {"index": 43, "position": [216, 219], "orth": "and", "lexemes": [{"lemma": "and", "mstag": "CCONJ", "disamb": true}]}, {"index": 44, "position": [220, 224], "orth": "turn", "lexemes": [{"lemma": "turn", "mstag": "VERB", "disamb": true}]}, {"index": 45, "position": [225, 229], "orth": "away", "lexemes": [{"lemma": "away", "mstag": "ADV", "disamb": true}]}, {"index": 46, "position": [230, 237], "orth": "because", "lexemes": [{"lemma": "because", "mstag": "SCONJ", "disamb": true}]}, {"index": 47, "position": [238, 239], "orth": "I", "lexemes": [{"lemma": "I", "mstag": "PRON", "disamb": true}]}, {"index": 48, "position": [240, 243], "orth": "was", "lexemes": [{"lemma": "be", "mstag": "AUX", "disamb": true}]}, {"index": 49, "position": [244, 246], "orth": "n’t", "lexemes": [{"lemma": "not", "mstag": "PART", "disamb": true}]}, {"index": 50, "position": [247, 252], "orth": "worth", "lexemes": [{"lemma": "worth", "mstag": "ADJ", "disamb": true}]}, {"index": 51, "position": [253, 260], "orth": "talking", "lexemes": [{"lemma": "talk", "mstag": "VERB", "disamb": true}]}, {"index": 52, "position": [261, 263], "orth": "to", "lexemes": [{"lemma": "to", "mstag": "ADP", "disamb": true}]}, {"index": 53, "position": [264, 264], "orth": ",", "lexemes": [{"lemma": ",", "mstag": "PUNCT", "disamb": true}]}, {"index": 54, "position": [265, 265], "orth": "”", "lexemes": [{"lemma": "\"", "mstag": "PUNCT", "disamb": true}]}, {"index": 55, "position": [266, 270], "orth": "said", "lexemes": [{"lemma": "say", "mstag": "VERB", "disamb": true}]}, {"index": 56, "position": [271, 276], "orth": "Thrun", "lexemes": [{"lemma": "Thrun", "mstag": "PROPN", "disamb": true}]}, {"index": 57, "position": [277, 277], "orth": ",", "lexemes": [{"lemma": ",", "mstag": "PUNCT", "disamb": true}]}, {"index": 58, "position": [278, 280], "orth": "in", "lexemes": [{"lemma": "in", "mstag": "ADP", "disamb": true}]}, {"index": 59, "position": [281, 283], "orth": "an", "lexemes": [{"lemma": "an", "mstag": "DET", "disamb": true}]}, {"index": 60, "position": [284, 293], "orth": "interview", "lexemes": [{"lemma": "interview", "mstag": "NOUN", "disamb": true}]}, {"index": 61, "position": [294, 298], "orth": "with", "lexemes": [{"lemma": "with", "mstag": "ADP", "disamb": true}]}, {"index": 62, "position": [299, 305], "orth": "Recode", "lexemes": [{"lemma": "Recode", "mstag": "PROPN", "disamb": true}]}, {"index": 63, "position": [306, 313], "orth": "earlier", "lexemes": [{"lemma": "early", "mstag": "ADV", "disamb": true}]}, {"index": 64, "position": [314, 318], "orth": "this", "lexemes": [{"lemma": "this", "mstag": "DET", "disamb": true}]}, {"index": 65, "position": [319, 323], "orth": "week", "lexemes": [{"lemma": "week", "mstag": "NOUN", "disamb": true}]}, {"index": 66, "position": [324, 324], "orth": ".", "lexemes": [{"lemma": ".", "mstag": "PUNCT", "disamb": true}]}, {"index": 67, "position": [325, 326], "orth": "\n\n", "lexemes": [{"lemma": "\n\n", "mstag": "SPACE", "disamb": true}]}], "text": "When Sebastian Thrun started working on self-driving cars at Google in 2007, few people outside of the company took him seriously. “I can tell you very senior CEOs of major American car companies would shake my hand and turn away because I wasn’t worth talking to,” said Thrun, in an interview with Recode earlier this week.\n\n"}
\ No newline at end of file
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
foobar, baz
{"base": {"woda": 16, "być": 5, "jeden": 1, "z": 2, "pospolity": 1, "substancja": 2, "w": 15, "wszechświat": 1, ".": 14, "cząsteczka": 2, "trzeci": 1, "bardzo": 2, "rozpowszechniony": 3, "molekuła": 1, "ośrodek": 1, "międzygwiazdowy": 1, ",": 13, "po": 1, "cząsteczkowy": 1, "wodór": 1, "i": 7, "tlenek": 1, "węgiel": 1, "również": 2, "szeroko": 1, "Układ": 1, "Słoneczny": 1, ":": 1, "stanowić": 1, "istotny": 1, "element": 1, "budowa": 2, "ceres": 1, "księżyc": 1, "lodowy": 1, "krążyć": 1, "wokół": 1, "planeta": 2, "-": 1, "olbrzym": 1, "jako": 2, "domieszka": 1, "występować": 4, "on": 3, "atmosfera": 2, "a": 2, "przypuszczać": 1, "się": 4, "że": 1, "duży": 1, "ilość": 2, "znajdować": 2, "wnętrze": 1, "ten": 1, "lód": 1, "także": 3, "na": 3, "część": 2, "planetoida": 1, "zapewne": 1, "obiekt": 1, "transneptunowych": 1, "powierzchnia": 2, "Ziemia": 2, "głównie": 1, "ocean": 2, "który": 1, "pokrywać": 1, "70": 1, "8": 1, "%": 1, "glob": 1, "ale": 1, "rzeka": 1, "jezioro": 1, "postać": 1, "stały": 1, "lodowiec": 1, "(": 2, "chmura": 1, "para": 1, "wodny": 1, ")": 2, "niektóry": 1, "związek": 1, "chemiczny": 1, "zawierać": 4, "swój": 1, "hydrat": 1, "–": 2, "określać": 1, "wówczas": 1, "miano": 1, "krystalizacyjny": 1, "zawartość": 3, "włączyć": 1, "struktura": 1, "minerał": 1, "płaszcz": 1, "móc": 1, "przekraczać": 1, "łączny": 1, "inny": 1, "zbiornik": 1, "powierzchniowy": 1, "nawet": 1, "dziesięciokrotnie": 1, "przyroda": 1, "roztwór": 1, "sól": 3, "gaz": 1, "najwięcej": 1, "mineralny": 3, "morski": 1, ";": 1, "najmniej": 1, "opad": 1, "atmosferyczny": 1, "o": 1, "mały": 1, "składnik": 1, "nazywać": 1, "miękki": 1, "natomiast": 1, "znaczny": 1, "wapń": 1, "magnez": 1, "twardy": 1, "oprócz": 1, "to": 1, "naturalny": 1, "rozpuścić": 1, "pochodzenie": 1, "organiczny": 1, "na przykład": 1, "mocznik": 1, "kwas": 1, "humusowy": 1, "i tym podobne": 1}}
\ No newline at end of file
This diff is collapsed.
When Sebastian Thrun started working on self-driving cars at Google in 2007, few people outside of the company took him seriously. “I can tell you very senior CEOs of major American car companies would shake my hand and turn away because I wasn’t worth talking to,” said Thrun, in an interview with Recode earlier this week.
Woda jest jedną z najpospolitszych substancji we Wszechświecie.
Cząsteczka wody jest trzecią najbardziej rozpowszechnioną molekułą w ośrodku międzygwiazdowym, po cząsteczkowym wodorze i tlenku węgla. Jest również szeroko rozpowszechniona w Układzie Słonecznym: stanowi istotny element budowy Ceres i księżyców lodowych krążących wokół planet-olbrzymów, jako domieszka występuje w ich atmosferach, a przypuszcza się, że duże jej ilości znajdują się we wnętrzach tych planet. Jako lód występuje także na części planetoid, a zapewne również na obiektach transneptunowych. Woda jest bardzo rozpowszechniona także na powierzchni Ziemi. Występuje głównie w oceanach, które pokrywają 70,8% powierzchni globu, ale także w rzekach, jeziorach i w postaci stałej w lodowcach. Część wody znajduje się w atmosferze (chmury, para wodna). Niektóre związki chemiczne zawierają cząsteczki wody w swojej budowie (hydraty – określa się ją wówczas mianem wody krystalizacyjnej). Zawartość wody włączonej w strukturę minerałów w płaszczu Ziemi może przekraczać łączną zawartość wody w oceanach i innych zbiornikach powierzchniowych nawet dziesięciokrotnie.
Woda występująca w przyrodzie jest roztworem soli i gazów. Najwięcej soli mineralnych zawiera woda morska i wody mineralne; najmniej woda z opadów atmosferycznych. Wodę o małej zawartości składników mineralnych nazywamy wodą miękką, natomiast zawierającą znaczne ilości soli wapnia i magnezu – wodą twardą. Oprócz tego wody naturalne zawierają rozpuszczone substancje pochodzenia organicznego, np. mocznik, kwasy humusowe itp.
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