Last active
July 24, 2018 04:59
-
-
Save AlexDel/19f85b9fe71dcd1220f7e8436a255099 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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