Skip to content

Instantly share code, notes, and snippets.

View joao141141's full-sized avatar
🐼
LET'S GO

João Henrique Amorim Silva joao141141

🐼
LET'S GO
View GitHub Profile
@joao141141
joao141141 / script.py
Created March 22, 2024 03:17
My first Perceptron
class Perceptron:
def __init__(self, num_inputs=2, weights=[1,1]):
self.num_inputs = num_inputs
self.weights = weights
def weighted_sum(self, inputs):
weighted_sum = 0
for i in range(self.num_inputs):
weighted_sum += self.weights[i]*inputs[i]
return weighted_sum
@joao141141
joao141141 / BOW2.py
Created February 23, 2024 03:50
Bow2
from spam_data import training_spam_docs, training_doc_tokens, training_labels, training_docs
from sklearn.naive_bayes import MultinomialNB
from sklearn.feature_extraction.text import CountVectorizer
test_text = """
Play around with the spam classifier!
"""
bow_vectorizer = CountVectorizer()
@joao141141
joao141141 / BOW.py
Created February 22, 2024 04:33
BAG-OF-WORDS LM (codecademy exercise)
from spam_data import training_spam_docs, training_doc_tokens, training_labels, test_labels, test_spam_docs, training_docs, test_docs
from sklearn.naive_bayes import MultinomialNB
def create_features_dictionary(document_tokens):
features_dictionary = {}
index = 0
for token in document_tokens:
if token not in features_dictionary:
features_dictionary[token] = index
index += 1
@joao141141
joao141141 / alienbot.py
Created February 22, 2024 03:57
EUREKA
import re
import random
class AlienBot:
def __init__(self):
self.name = None
self.alienbabble = {
'describe_planet_intent': r'.*(how|tell.*about|interest.*in).*your.*planet',
'answer_why_intent': r'why are you.*(here|asking me?\s?so?\s?many questions)\??',
'cubed_intent': r'can.*you.*cube.*number (\d+)?',
@joao141141
joao141141 / alienbot
Created February 22, 2024 03:53
stuck in this
import re
import random
class AlienBot:
def __init__(self):
self.name = None
self.alienbabble = {
'describe_planet_intent': r'.*(how|tell.*about|interest.*in).*your.*planet',
'answer_why_intent': r'why are you.*(here|asking me?\s?so?\s?many questions)\??',
'cubed_intent': r'can.*you.*cube.*number (\d+)?',
public class MadLibs {
/*
This program generates a mad libbed story.
Author: João
Date: 02/20/2024
*/
public static void main(String[] args){
String name1 = "Carlos";
String adjective1 = "good";
String adjective2 = "bad";
from nltk import pos_tag, RegexpParser
from tokenize_words import word_sentence_tokenize
from chunk_counters import np_chunk_counter, vp_chunk_counter
text = open("the_iliad.txt",encoding='utf-8').read().lower()
word_tokenized_text = word_sentence_tokenize(text)
@joao141141
joao141141 / Gradebook.py
Created February 9, 2024 06:32
gradebook(exercise)
last_semester_gradebook = [["politics", 80], ["latin", 96], ["dance", 97], ["architecture", 65]]
# Your code below:
subjects = ['physics', 'calculus', 'poetry', 'history']
grades = [98, 97, 85, 88]
gradebook = [[subjects[0], grades[0]], [subjects[1], grades[1]], [subjects[2], grades[2]], [subjects[3], grades[3]]]
@joao141141
joao141141 / loops.py
Created February 9, 2024 06:29
LIIIIIIIIIIITS
# Your code below:
first_names = ['Ainsley', 'Ben', 'Chani', 'Depak']
preferred_size = ['Small', 'Large', 'Medium']
preferred_size.append('Medium')
customer_data = [['Ainsley', 'Small', True], ['Ben', 'Large', False], ['Chani', 'Medium', True], ['Depak', 'Medium', False]]
@joao141141
joao141141 / script.py
Created February 9, 2024 06:26
My first Chat Bot
# Define your functions
def coffee_bot():
print('Welcome to the cafe!')
size = get_size()
print(size)
drink_type = get_drink_type()
print(drink_type)