This file contains hidden or 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 transformers import ( | |
AutoTokenizer, | |
DataCollatorWithPadding, | |
TrainingArguments, | |
Trainer, | |
AutoModelForSequenceClassification, | |
) | |
from datasets import load_dataset, ClassLabel | |
import numpy as np | |
import evaluate |
This file contains hidden or 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
# Fetch some text content in two different categories | |
from wikipediaapi import Wikipedia | |
wiki = Wikipedia('RAGBot/0.0', 'en') | |
docs = [{"text": x, | |
"category": "person"} | |
for x in wiki.page('Hayao_Miyazaki').text.split('\n\n')] | |
docs += [{"text": x, | |
"category": "film"} | |
for x in wiki.page('Spirited_Away').text.split('\n\n')] |
This file contains hidden or 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 collections import Counter | |
# Part 1 | |
inputs = [x.strip() for x in open('inputs.txt', 'r').readlines()] | |
gamma_str = '' | |
epsilon_str = '' | |
for i in range(len(inputs[0])): | |
col_count = Counter([x[i] for x in inputs]) | |
if col_count['1'] > col_count['0']: |
This file contains hidden or 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
# Please use the following encoding: utf-8, thanks! | |
import networkx as nx | |
''' Part 1''' | |
graph = nx.read_edgelist('./data/day6_input.txt', delimiter=')', create_using=nx.DiGraph) | |
orbit_count = sum(len(nx.ancestors(G=graph, source=node)) for node in graph.nodes) | |
print(orbit_count) | |
''' Part 2 ''' | |
undir_graph = nx.read_edgelist('./data/day6_input.txt', delimiter=')', create_using=nx.Graph) | |
shortest = len(nx.shortest_path(undir_graph, source="YOU", target="SAN")) - 3 |
This file contains hidden or 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 tweepy | |
"""Consumer key&secret key from http://dev.twitter.com""" | |
CONSUMER_KEY = '' | |
CONSUMER_SECRET = '' | |
def login(consumer_key, consumer_secret): | |
logon = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
logonurl = logon.get_authorization_url() | |
"""Authenticate tweet deleter""" |