MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / test_ngrams

Method test_ngrams

tests/licensedcode/test_tokenize.py:591–605  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

589 test_data_dir = TEST_DATA_DIR
590
591 def test_ngrams(self):
592 tokens = '''
593 Redistribution and use in source and binary are permitted.
594 '''.split()
595
596 result = list(ngrams(tokens, ngram_length=4))
597 expected = [
598 ('Redistribution', 'and', 'use', 'in'),
599 ('and', 'use', 'in', 'source'),
600 ('use', 'in', 'source', 'and'),
601 ('in', 'source', 'and', 'binary'),
602 ('source', 'and', 'binary', 'are'),
603 ('and', 'binary', 'are', 'permitted.')
604 ]
605 assert result == expected
606
607 def test_ngrams_with_None(self):
608 tokens = ['Redistribution', 'and', 'use', None, 'in', 'source', 'and', 'binary', 'are', None]

Callers

nothing calls this directly

Calls 2

ngramsFunction · 0.90
splitMethod · 0.45

Tested by

no test coverage detected