<commit_before>from datetime import datetime, timedelta
import time
import string
import random
from pattern.en import parsetree, singularize
from pattern.search import search

def removePunctuation(str):
    return str.translate(None, string.punctuation)

# input: g.user, i.e. mongodb user object
def sayHiTimeZone(user):
    user_now = getUserTime(user)
    if recentChat(user):
        return "Hi again"
    if user_now.hour < 12:
        return "Good morning"
    elif user_now.hour < 19:
        return "Good afternoon"
    else:
        return "Good evening"

# input: g.user
def sayByeTimeZone(user):
    user_now = getUserTime(user)
    goodnights = ["Good night", "Have a good night", "Bye now", "See you later"]
    byes = ["Goodbye", "Bye then", "See you later", "Bye, have a good day"]
    
    if user_now.hour > 20:
        return "%s :)"%goodnights[random.randint(0,len(goodnights))]
    else:
        return "%s :)"%byes[random.randint(0,len(byes))]

# input: g.user
def recentChat(user):
    last_seen = user['last_seen'] 
    timestamp = datetime.strptime(last_seen,"%Y-%m-%d %H:%M:%S")
    time_since_chat = datetime.now() - timestamp
    recent60min = timedelta(minutes=60)
    if time_since_chat < recent60min:
        return True
    else:
        return False

# input: g.user
def getUserTime(user):
    user_tz = user['timezone']
    offset = time.timezone if (time.localtime().tm_isdst == 0) else time.altzone
    server_tz = offset / 60 / 60 * -1
    time_diff = user_tz - server_tz
    server_now = datetime.now()
    return server_now + timedelta(hours=time_diff)

def isGreetings(inp_str):
    string = inp_str.lower()
    greetings = ['hi','hey','hello', 'greetings', 'good morning', 'good afternoon', 'good evening']
    for word in greetings:
        if word in string:
            return True
    return False

def isGoodbye(inp_str):
    string = inp_str.lower()
    byes = ['bye', 'see you']<commit_msg>Change Hi and Bye NLP logic<commit_after>from datetime import datetime, timedelta
import time
import string
import random
from pattern.en import parsetree, singularize
from pattern.search import search

def removePunctuation(str):
    return str.translate(None, string.punctuation)

# input: g.user, i.e. mongodb user object
def sayHiTimeZone(user):
    user_now = getUserTime(user)
    if recentChat(user):
        return "Hi again"
    if user_now.hour < 12:
        return "Good morning"
    elif user_now.hour < 19:
        return "Good afternoon"
    else:
        return "Good evening"

# input: g.user
def sayByeTimeZone(user):
    user_now = getUserTime(user)
    goodnights = ["Good night", "Have a good night", "Bye now", "See you later"]
    byes = ["Goodbye", "Bye then", "See you later", "Bye, have a good day"]
    
    if user_now.hour > 20:
        return "%s :)"%goodnights[random.randint(0,len(goodnights))]
    else:
        return "%s :)"%byes[random.randint(0,len(byes))]

# input: g.user
def recentChat(user):
    last_seen = user['last_seen'] 
    timestamp = datetime.strptime(last_seen,"%Y-%m-%d %H:%M:%S")
    time_since_chat = datetime.now() - timestamp
    recent60min = timedelta(minutes=60)
    if time_since_chat < recent60min:
        return True
    else:
        return False

# input: g.user
def getUserTime(user):
    user_tz = user['timezone']
    offset = time.timezone if (time.localtime().tm_isdst == 0) else time.altzone
    server_tz = offset / 60 / 60 * -1
    time_diff = user_tz - server_tz
    server_now = datetime.now()
    return server_now + timedelta(hours=time_diff)

def isGreetings(inp_str):
    string = inp_str.lower().split(" ")
    greetings = ['hi','hey','hello', 'greetings', 'good morning', 'good afternoon', 'good evening']
    for word in greetings:
        if word in string:
            return True
    return False

def isGoodbye(inp_str):
    string = inp_str.lower().split(" ")
    byes = ['bye', 'see you']
{'fraction_non_alphanumeric': 0.12468063362289218, 'fraction_numerical': 0.010219724067450179, 'mean_word_length': 3.2833698030634575, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2426049', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1293, 'n_words': 358}