def test_text_extractor(): stim = ComplexTextStim(join(TEXT_DIR, 'sample_text.txt'), columns='to', default_duration=1) td = DictionaryExtractor(join(TEXT_DIR, 'test_lexical_dictionary.txt'), variables=['length', 'frequency']) assert td.data.shape == (7, 2) result = td.transform(stim)[2].to_df() assert result['duration'][0] == 1 assert result.shape == (1, 6) assert np.isclose(result['frequency'][0], 11.729, 1e-5)
def test_dictionary_extractor(): td = DictionaryExtractor(join(TEXT_DIR, 'test_lexical_dictionary.txt'), variables=['length', 'frequency']) assert td.data.shape == (7, 2) stim = TextStim(text='annotation') result = td.transform(stim).to_df() assert np.isnan(result['onset'][0]) assert 'length' in result.columns assert result['length'][0] == 10 stim2 = TextStim(text='some') result = td.transform(stim2).to_df() assert np.isnan(result['onset'][0]) assert 'frequency' in result.columns assert np.isnan(result['frequency'][0])