Skip to content

Instantly share code, notes, and snippets.

@AlexDel
Last active July 24, 2018 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexDel/19f85b9fe71dcd1220f7e8436a255099 to your computer and use it in GitHub Desktop.
Save AlexDel/19f85b9fe71dcd1220f7e8436a255099 to your computer and use it in GitHub Desktop.
import re
file_emotion = open('fear1.txt', 'r', encoding='utf-8')
text_emotion = file_emotion.read().lower()
words = text_emotion.split()
def CountFearFeatures_time(text):
features_time = []
for word in text:
if re.match ('минут.*', word):
features_time.append(word)
elif re.match ('секунд.*', word):
features_time.append(word)
elif re.match ('момент*', word):
features_time.append(word)
elif re.match ('час*', word):
features_time.append(word)
elif re.match ('дн*', word): # дня, дню, днем, дне и проч.
features_time.append(word)
elif re.match ('ден*', word): # день + уменьш.: денек, денька, деньку, деньком, деньке и проч.
features_time.append(word)
return 'Доля лексики с семой "короткий промежуток времени": {0}'.format(len(features_time)/len(words))
print(CountFearFeatures_time(words))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment