This site is developed to XHTML and CSS2 W3C standards.
If you see this paragraph, your browser does not support those standards and you
need to upgrade. Visit WaSP
for a variety of options.
Paste #83
Posted by: HabrArchive
Posted on: 2026-01-14 15:51:43
Age: 19 days ago
Views: 11
def extract_percept_descriptions(context_text):
tokens = [t.text.lower() for t in tokenize(context_text) if t.text.isalpha()]
lemmas = [morph.parse(w)[0].normal_form for w in tokens]
percept_positions = [i for i, l in enumerate(lemmas) if l in percept_lemmas]
descriptions = {'visual': [], 'auditory': [], 'emotional': []}
for pos in percept_positions:
start = max(0, pos - 5)
end = min(len(lemmas), pos + 6)
window_lemmas = lemmas[start:end]
for l in window_lemmas:
if l in visual_lemmas:
descriptions['visual'].append(l)
elif l in auditory_lemmas:
descriptions['auditory'].append(l)
elif l in emotional_lemmas:
descriptions['emotional'].append(l)
Download raw |
Create new paste