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
from datetime import date | |
def group_week_numbers(start_date, end_date, group_by_count): | |
"""Group week numbers into [group_by_count]""" | |
initial_weeknum = start_date.isocalendar()[1] | |
end_weeknum = end_date.isocalendar()[1] | |
# end year should be from the isocalendar | |
# example if you use date(2025, 12, 31) isocalendar will be | |
# 2025 and week 1 | |
end_year = end_date.isocalendar()[0] |
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 | |
from nltk import ( | |
FreqDist, | |
ngrams, | |
word_tokenize | |
) | |
def tokenize_phrases(phrases): | |
ret = [] | |
for phrase in phrases: |
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
from nltk.corpus import words | |
def spellcheck(w): | |
if w in words.words(): | |
return True | |
return False |
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
from nltk import word_tokenize, ngrams, FreqDist | |
from nltk.corpus import cmudict | |
import string | |
f = open('poem.txt', 'r') | |
doc = f.readlines() | |
texts = ' '.join(doc) | |
texts = texts.replace('\n', ' ') | |
tokenized = word_tokenize(texts) |
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
# homebrew | |
# https://brew.sh | |
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
# git | |
$ brew install git | |
# pip | |
$ sudo easy_install pip |
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
# wadpata alaws wamaga ): | |
VOWELS = ["a", "e", "i", "o", "u"] | |
ADD_S = ["n", "t", "w"] | |
def syllabicate(word): | |
# Yorme style syllabication | |
# TODO: Incomplete find other test cases | |
word = word.lower() |
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
0x119E2c5b180D8d2Bee8c2Fca42E9f4443A4D6fB2 |
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 json | |
import requests | |
from bottle import debug, request, route, run | |
GRAPH_URL = "https://graph.facebook.com/v2.6" | |
VERIFY_TOKEN = 'YOUR_VERIFY_TOKEN' | |
PAGE_TOKEN = 'YOUR_PAGE_TOKEN' | |
def send_to_messenger(ctx): |
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 json | |
import requests | |
from bottle import debug, request, route, run | |
def build_service_url(service_url, cid): | |
"""build the service url""" | |
service_url = '{0}/v3/conversations/{1}/activities/'.format(service_url, cid) | |
return service_url |
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
from nltk.chat.util import Chat, reflections | |
pairs = [ | |
[ | |
r"My name is (.*)", | |
['hello %1', '%1 mabuhay ka'], | |
], | |
[ | |
r'hi', | |
['hello', 'kamusta', 'mabuhay',], |
NewerOlder