Skip to content

Instantly share code, notes, and snippets.

View dzakyputra's full-sized avatar

Dzaky Widya Putra dzakyputra

View GitHub Profile
# Portfolio preprocessing
values = []
# Iterate the dataframe
for index, row in portfolio.iterrows():
# Set the default value
new_value = [0,0,0,0]
from matplotlib.colors import ListedColormap
from tqdm import tqdm
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
import pandasql as pdsql
import seaborn as sns
import pandas as pd
import numpy as np
import math
from telegram.ext import Updater, CommandHandler
import pandas as pd
import logging
# Set the logging function to print the error message whenever it happens
logging.basicConfig(level=logging.DEBUG, format='%(levelname)s - %(message)s')
logger = logging.getLogger()
logger.setLevel(logging.ERROR)
def main():
# Initiate the bot and add command handler
updater = Updater('YOUR_BOT_TOKEN', use_context=True)
updater.dispatcher.add_handler(CommandHandler('word', send_word))
# Run the bot
updater.start_polling()
updater.idle()
def send_word(update, context):
# Read the dataset and pick a random word
dictionary = pd.read_csv('dictionary.csv')
word = dictionary['word'].sample(1).values[0]
# Get the user chat_id for sending back the message
chat_id = update.message.chat_id
# Send the word and the audio
from google.cloud import texttospeech
from bs4 import BeautifulSoup
import pandas as pd
import requests
import re
def get_hangeul():
def create_audio(text, language='ko-KR'):
# Instantiates a client
client = texttospeech.TextToSpeechClient()
# Set the text input to be synthesized
synthesis_input = texttospeech.types.SynthesisInput(text=text)
# Build the voice request, select the language code ("en-US") and the ssml
# voice gender ("neutral")
def get_hangeul():
# Scrape the website and get list of titles
url = 'https://www.bbc.com/korean/popular/read'
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')
titles = soup.findAll('span',
{'class': 'most-popular-list-item__headline'})
# Iterate through titles -> remove punctuation -> append to the list
from google.cloud import texttospeech
from bs4 import BeautifulSoup
import pandas as pd
import requests
import re
import os
import io
import sys
import subprocess
import tesserocr
from pyspark.sql import SparkSession
# Initiate spark session
spark = SparkSession.builder \