Skip to content

Instantly share code, notes, and snippets.

View amn41's full-sized avatar

Alan Nichol amn41

View GitHub Profile
from rasa_dm.actions import Action
import requests
class ActionHTTPRequest(Action):
def name(self):
return "make_request"
def run(self, dispatcher, tracker, domain):
url = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22nome%2C%20ak%22)&format=json'
result = requests.get(url).json()
@amn41
amn41 / process_logs.py
Created July 31, 2017 14:20
read rasa nlu logs, optionally reprocess, and dump to file
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from builtins import str as text
import argparse
import io
import json
import sys, os
from mitie import *
trainer = text_categorizer_trainer("/path/to/total_word_feature_extractor.dat")
data = {} # same as before - omitted for brevity
for label in training_examples.keys():
for text in training_examples[label]["examples"]:
tokens = tokenize(text)
def find_similar_words(embed,text,refs,thresh):
C = np.zeros((len(refs),embed.W.shape[1]))
for idx, term in enumerate(refs):
if term in embed.vocab:
C[idx,:] = embed.W[embed.vocab[term], :]
tokens = text.split(' ')
import rinocloud as rino
import shutil, os
import subprocess
import hashlib
"""
persist = Persistor(config.rino_token,config.rino_dir)
def save_model_new(persist,model_file,score):
temp_file="tmp_{0:06d}.txt".format(random.choice(range(10000)))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import sys, os
from mitie import *
sample = ner_training_instance(["I", "am", "looking", "for", "some", "cheap", "Mexican", "food", "."])
sample.add_entity(xrange(5,6), "pricerange")
sample.add_entity(xrange(6,7), "cuisine")
# And we add another training example
sample2 = ner_training_instance(["show", "me", "indian", "restaurants", "in", "the", "centre", "."])
sample2.add_entity(xrange(2,3), "cuisine")
\emph{hello}
@amn41
amn41 / epic-first-attempt
Last active May 10, 2016 16:59
attempt at using epic NER on plaintext file
import epic.models.{NerSelector, ParserSelector}
import epic.parser.ParserAnnotator
import epic.preprocess
import epic.preprocess.{TreebankTokenizer, MLSentenceSegmenter}
import epic.sequences.{SemiCRF, Segmenter}
import epic.slab.{EntityMention, Token, Sentence}
import epic.trees.{AnnotatedLabel, Tree}
import epic.util.SafeLogging
while ( not formData.is_complete() ):
questionKey = formData.first_missing_field()
ask(questions[questionKey])