def test_non_unique_with_dict(self): t_input = 'foo bar baz foo bar' (new, res) = parse(t_input, ['bar', 'baz']) (count, word, context) = res['bar'] assert len(new) == 1 assert count == 2
def test_non_unique(self): t_input = 'foo bar baz foo bar' (new, res) = parse(t_input, []) (count, word, context) = res['foo'] assert len(new) == len(t_input.split()) - 2 assert count == 2
def test_with_dict(self): t_input = 'foo bar baz qux' (new, res) = parse(t_input, ['bar', 'qux']) (count, word, context) = res['bar'] assert len(new) == len(t_input.split()) - 2 assert count == 1
def parse_text(text_id): dictionary = map(str, execute(db(), (words() | select(f_stem)))) (new, nfo) = parse(api.get_text(text_id), dictionary) map( lambda stem: api.add_note('word', 'words', { 'Stem': stem, 'TextId': str(text_id), 'Count': str(0) }), new) map( lambda (stem, (count, word, context)): api.upd_note( api.get_note_id('word', stem), { 'Count': lambda ov: str(int(ov) + count), 'Context': lambda ov: (ov if ov != empty_field() else '') + context, 'Words': lambda ov: (ov if ov != empty_field() else '') + word }), nfo.iteritems()) api.upd_note(text_id, {}, ['parsed'])
def test_base(self): t_input = 'foo bar baz qux' (new, _) = parse(t_input, []) assert len(new) == len(t_input.split())