Better commenting on functions and conditions

This commit is contained in:
2017-07-29 12:35:26 +02:00
parent ae8089eb90
commit c3ee118e38

View File

@@ -3,7 +3,7 @@
# @Author: KevinMidboe # @Author: KevinMidboe
# @Date: 2017-07-29 11:56:24 # @Date: 2017-07-29 11:56:24
# @Last Modified by: KevinMidboe # @Last Modified by: KevinMidboe
# @Last Modified time: 2017-07-29 12:27:31 # @Last Modified time: 2017-07-29 12:34:58
from fuzzywuzzy import process from fuzzywuzzy import process
@@ -16,13 +16,16 @@ weather_nouns = ['cleary sky', 'fair', 'cloudy', 'rain showers', 'rain', 'sleet'
# and then match the second to list and add that emoji # and then match the second to list and add that emoji
# REGEX this bitch up # REGEX this bitch up
# Splits and lowers the condition text for easier parsing
def splitCondition(condition): def splitCondition(condition):
condition = condition.lower() condition = condition.lower()
return condition.split() return condition.split()
# Trying to analyze the semantics of the condition text
def findConditionContext(condition_text): def findConditionContext(condition_text):
condition_expression = splitCondition(condition_text) condition_expression = splitCondition(condition_text)
# Iterate over each word and find what matches 100%
for expression_value in condition_expression: for expression_value in condition_expression:
noun_matches = process.extract(expression_value, weather_nouns) noun_matches = process.extract(expression_value, weather_nouns)
print(expression_value + ': ' + str(noun_matches)) print(expression_value + ': ' + str(noun_matches))