Skip to content

Instantly share code, notes, and snippets.

View EnkrateiaLucca's full-sized avatar

LUCAS SOARES EnkrateiaLucca

View GitHub Profile
@EnkrateiaLucca
EnkrateiaLucca / yaba.py
Created July 7, 2020 23:36
yabadabaduuu
for i,url in enumerate(df["links"][last_index:]):
webbrowser.open(url)
start_session = time.time()
date = get_date()
df["date"][i] = date
att_level = float(input("Input the attention level for this
input (0-10):"))
df["attention_level"][i] = att_level
next_inp = input("Press enter to go to next link or q to quit
training for now")
@EnkrateiaLucca
EnkrateiaLucca / learn_this.py
Created July 8, 2020 16:24
Setting up the dataset
def set_up_dataset(csv_file="dataset.csv",text_file='dataset.txt'):
"""
Creates a Dataframe from a text file with urls.
The columns are:
attention_level -> input a number representing how much attention the user will give to that source
session_time -> How long it took to finish studying that source
date -> The date of this session
session_score -> The subjective score the user gives to its own performance on that content.
"""
df = pd.read_csv(text_file, sep=" ", header=None)
@EnkrateiaLucca
EnkrateiaLucca / learn_this.py
Created July 8, 2020 16:26
The forward pass on the sources
for i,url in enumerate(df["links"][last_index:]): # Looping over the links
webbrowser.open(url) # Opens each link on the default browser
start_session = time.time()
date = get_date()
df["date"][i] = date # Stores the date
att_level = float(input("Input the attention level for this input (0-10):")) # Requests a score of attention
df["attention_level"][i] = att_level
next_inp = input("Press enter to go to next link or q to quit training for now") # To go to the next link
if next_inp == "q":
df["last_index"] = i
@EnkrateiaLucca
EnkrateiaLucca / touch_typing_tutor.py
Created July 13, 2020 04:04
App to help with touch-typing
# source for the stopwatch: https://stackoverflow.com/questions/31995804/stopwatch-on-tkinter-creating-a-class
import tkinter as tk
from tkinter import messagebox
import numpy as np
import os
import natsort
import shutil
import random
import sys
import time
@EnkrateiaLucca
EnkrateiaLucca / tokens.py
Created July 24, 2020 17:25
tokenization
from nltk import word_tokenize
# Loading my article in the article.txt file
with open("article.txt", "r", encoding="utf8") as intro:
text = intro.readlines()
# Selecting a sentence as a string
sentence = text[3]
print(word_tokenize(sentence))
from nltk.stem import PorterStemmer, LancasterStemmer
#Instantiating the Stemmer classes from nltk
porter = PorterStemmer()
lancaster = LancasterStemmer()
# Selecting a Sentence
sentence = text[3]
# Making a nice print output
print("Sentence:")
print("'" + sentence + "'")
print("{0:20} {1:20}".format("Ported Stemmer", "Lancaster Stemmer"))
@EnkrateiaLucca
EnkrateiaLucca / lemma.py
Created July 24, 2020 17:27
lemmatization
import nltk
from nltk.stem import WordNetLemmatizer
# Instantiating the lemmatizer class from nltk
wordnet_lemmatizer = WordNetLemmatizer()
# List of verbs and adjectives to feed to the lemmatizer
verbs = ["thinking", "wondering", "reflecting"]
adjectives = ["better", "brighter", "smarter"]
# Making a nice print for both
print("Verbs")
print("{0:20}{1:20}".format("Word","Lemma"))
import nltk
from nltk.stem import WordNetLemmatizer
# Instantiating the lemmatizer class from nltk
wordnet_lemmatizer = WordNetLemmatizer()
# List of verbs and adjectives to feed to the lemmatizer
verbs = ["thinking", "wondering", "reflecting"]
adjectives = ["better", "brighter", "smarter"]
# Print them in parallel
import spacy
sp = spacy.load("en_core_web_sm")
sentence = text[-7]
sent_tokens = word_tokenize(sentence)
pos_tagged = nltk.pos_tag(text)
sen = sp(u"What matters most is using it")
spacy.displacy.render(sen, style='dep', jupyter=True, options={'distance': 100})
@EnkrateiaLucca
EnkrateiaLucca / chunking.py
Last active July 24, 2020 19:06
chunking
import spacy
sp = spacy.load("en_core_web_sm")
sentence = "Only accept truths that are absolutely evident"
#Tokenizing the sentence
sentence_token = word_tokenize(sentence)
# Tagging the tokens of the sentence
sentence_tagged = nltk.pos_tag(sentence_token)
print(sentence_tagged)
# Stablishing a pattern to give to the chunker