🙇♂️
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 TrieNode: | |
def __init__(self): | |
self.child = {} | |
self.last = False |
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 TrieNode: | |
def __init__(self): | |
self.child = {} | |
self.last = False | |
class Trie: | |
def __init__(self): | |
self.root = TrieNode() | |
def insert(self, 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 TrieNode: | |
def __init__(self): | |
self.child = {} | |
self.last = False | |
class Trie: | |
def __init__(self): | |
self.root = TrieNode() | |
def insert(self, 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 TrieNode: | |
def __init__(self): | |
self.child = {} | |
self.last = False | |
class Trie: | |
def __init__(self): | |
self.root = TrieNode() | |
def insert(self, 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 TrieNode: | |
def __init__(self): | |
self.child = {} | |
self.last = False | |
class Trie: | |
def __init__(self): | |
self.root = TrieNode() | |
def insert(self, 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
#!/usr/bin/env python | |
import collections | |
import requests | |
import config | |
import get_collectionids | |
from operator import itemgetter | |
def send_request(parameters, api): |
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
document_embeddings = DocumentRNNEmbeddings(word_embeddings, hidden_size=512, reproject_words=True, reproject_words_dimension=256, rnn_type='LSTM', rnn_layers=1, bidirectional=False) | |
classifier = TextClassifier(document_embeddings, label_dictionary=corpus.make_label_dictionary(), multi_label=False) | |
trainer = ModelTrainer(classifier, corpus) | |
trainer.train('./model', max_epochs=20, patience=5, mini_batch_size=32, learning_rate=0.1) |
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 initialize_embeddings(): | |
""" | |
Summary: | |
Stacks the list of pre-trained embedding vectors to be used as word representation (in concat.) | |
Return: | |
list: Returns list of pretrained embeddings vectors | |
""" | |
word_embeddings = [ | |
WordEmbeddings('glove'), | |
FlairEmbeddings('news-forward'), |
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 segment_data(data_file): | |
try: | |
import pandas as pd | |
except ImportError: | |
raise | |
data = pd.read_csv(data_file, encoding='latin-1').sample(frac=1).drop_duplicates() | |
data = data[['classes', 'title']].rename(columns={"classes":"label", "title":"text"}) | |
data['label'] = '__label__' +data['label'].astype(str) | |
data['text'] = data['text'].apply(lambda k: k.lower().strip()) |
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 random | |
import os | |
from locust import HttpLocust, TaskSet, task | |
TEST_DATA_PATH = 'test.csv' | |
def load_test_sentences(): | |
utterances = [] | |
with open(TEST_DATA_PATH, 'r') as fp: | |
for row in fp: |