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
| def question(request, question_id): | |
| question = get_object_or_404(Question, pk=question_id) | |
| if request.method == 'POST': | |
| # create a form instance and populate it with data from the request: | |
| form = AnswerForm(request.POST) | |
| if form.is_valid(): | |
| content = form.cleaned_data.get('answer') | |
| if len(content) > 20: |
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 django.shortcuts import get_object_or_404, render, redirect | |
| from django.http import HttpResponseRedirect, HttpResponse | |
| from django.urls import reverse | |
| from .models import Question, Essay | |
| from .forms import AnswerForm | |
| from .utils.model import * | |
| from .utils.helpers import * |
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 sklearn.cross_validation import KFold | |
| from sklearn.linear_model import LinearRegression | |
| from sklearn.metrics import cohen_kappa_score | |
| cv = KFold(len(X), n_folds=5, shuffle=True) | |
| results = [] | |
| y_pred_list = [] | |
| count = 1 |
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 keras.layers import Embedding, LSTM, Dense, Dropout, Lambda, Flatten | |
| from keras.models import Sequential, load_model, model_from_config | |
| import keras.backend as K | |
| def get_model(): | |
| """Define the model.""" | |
| model = Sequential() | |
| model.add(LSTM(300, dropout=0.4, recurrent_dropout=0.4, input_shape=[1, 300], return_sequences=True)) | |
| model.add(LSTM(64, recurrent_dropout=0.4)) | |
| model.add(Dropout(0.5)) |
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 numpy as np | |
| import nltk | |
| import re | |
| from nltk.corpus import stopwords | |
| from gensim.models import Word2Vec | |
| def essay_to_wordlist(essay_v, remove_stopwords): | |
| """Remove the tagged labels and word tokenize the sentence.""" | |
| essay_v = re.sub("[^a-zA-Z]", " ", essay_v) | |
| words = essay_v.lower().split() |
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
| Importing the Data | |
| #!pip install -U gensim | |
| #!pip install -U nltk | |
| #!python -m nltk.downloader punkt | |
| #!python -m nltk.downloader stopwords | |
| #!pip install django | |
| !pip install django-widget-tweaks | |
| Collecting django-widget-tweaks | |
| Downloading https://files.pythonhosted.org/packages/eb/16/86c8fdbc774c97a93028846cef1ddbe4f3ebb1ff933b54aed920cf619bf4/django_widget_tweaks-1.4.3-py2.py3-none-any.whl | |
| menpo 0.8.1 has requirement matplotlib<2.0,>=1.4, but you'll have matplotlib 2.2.3 which is incompatible. |
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
| Importing the Data | |
| #!pip install -U gensim | |
| #!pip install -U nltk | |
| #!python -m nltk.downloader punkt | |
| #!python -m nltk.downloader stopwords | |
| #!pip install django | |
| !pip install django-widget-tweaks | |
| Collecting django-widget-tweaks | |
| Downloading https://files.pythonhosted.org/packages/eb/16/86c8fdbc774c97a93028846cef1ddbe4f3ebb1ff933b54aed920cf619bf4/django_widget_tweaks-1.4.3-py2.py3-none-any.whl | |
| menpo 0.8.1 has requirement matplotlib<2.0,>=1.4, but you'll have matplotlib 2.2.3 which is incompatible. |
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
| { | |
| "pipeline": "spacy_sklearn", | |
| "path":"./models/nlu", | |
| "data":"./data/data.json" | |
| } |
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
| { | |
| "text": "Hello", | |
| "intent": "greet", | |
| "entities": [] | |
| }, | |
| { | |
| "text": "goodbye", | |
| "intent": "goodbye", | |
| "entities": [] | |
| }, |
NewerOlder