2023-11-18 10:21:48 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
* Podziel zmienną `text` na słowa, korzystając z metody split.
|
|
|
|
* Dodaj do listy `oov`, wszystkie słowa (bez powtórzeń), które nie są zawarte w liście `vocab`.
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
text = "this is a string , which i will use for string testing"
|
|
|
|
vocab = [',', 'this', 'is', 'a', 'which', 'for', 'will', 'i']
|
|
|
|
|
2023-11-18 16:42:28 +01:00
|
|
|
text = text.split(' ')
|
|
|
|
|
2023-11-18 10:21:48 +01:00
|
|
|
oov = []
|
2023-11-18 16:42:28 +01:00
|
|
|
|
|
|
|
for word in text:
|
|
|
|
if word not in vocab and word not in oov:
|
|
|
|
oov.append(word)
|
|
|
|
|
|
|
|
print(oov)
|
|
|
|
|