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 twitter | |
import os | |
from urllib.request import urlopen | |
from datetime import datetime | |
import twitter | |
import pandas as pd | |
import json | |
auth = twitter.OAuth(consumer_key = os.environ["COMSUMER_KEY"], | |
consumer_secret = os.environ["COMSUMER_SECRET"], |
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 urllib.request import urlopen | |
import json | |
from googlesearch import search | |
from bs4 import BeautifulSoup as bs | |
from gensim.models import word2vec | |
import numpy as np | |
from gensim.models import KeyedVectors | |
import MeCab | |
import pandas as pd | |
from datetime import datetime |
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 hashlib import sha256 | |
class Node: | |
def __init__(self, data): | |
self.left = None | |
self.right = None | |
self.parent = None | |
self.sibling = None | |
self.position = None | |
self.data = data |
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
class Node: | |
def __init__(self, data): | |
self.left = None | |
self.right = None | |
self.parent = None | |
self.sibling = None | |
self.position = None | |
self.data = data | |
self.hash = sha256(data.encode()).hexdigest() |
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
class Tree: | |
def __init__(self, leaves): | |
self.leaves = [Node(leaf) for leaf in leaves] | |
self.layer = self.leaves[::] | |
self.root = None | |
self.build_tree() | |
def build_layer(self): | |
new_layer = [] | |
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
def build_layer(self): | |
new_layer = [] | |
if len(self.layer) % 2 == 1: | |
self.layer.append(self.layer[-1]) | |
for i in range(0, len(self.layer), 2): | |
left = self.layer[i] | |
right = self.layer[i+1] | |
parent = Node(left.hash + right.hash) |
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
def build_tree(self): | |
while len(self.layer) > 1: | |
self.build_layer() | |
self.root = self.layer[0].hash |
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
def search(self, data): | |
target = None | |
hash_value = sha256(data.encode()).hexdigest() | |
for node in self.leaves: | |
if node.hash == hash_value: | |
target = node | |
return target |
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
def get_pass(self, data): | |
target = self.search(data) | |
markle_pass = [] | |
if not(target): | |
return | |
markle_pass.append(target.hash) | |
while target.parent: | |
sibling = target.sibling | |
markle_pass.append((sibling.hash, sibling.position)) | |
target = target.parent |
OlderNewer