From 077e846c68ca5b6d937b47ed209f919dd01fa667 Mon Sep 17 00:00:00 2001 From: proofx Date: Mon, 2 Jul 2018 15:25:59 +0300 Subject: [PATCH] VJB-47 Create patch for W2V. --- jobboard/migrations/0001_initial.py | 13 +------------ quiz/tasks.py | 6 +++++- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/jobboard/migrations/0001_initial.py b/jobboard/migrations/0001_initial.py index 2e397d5..b773cf2 100644 --- a/jobboard/migrations/0001_initial.py +++ b/jobboard/migrations/0001_initial.py @@ -1,9 +1,8 @@ -# Generated by Django 2.0.3 on 2018-05-28 10:45 +# Generated by Django 2.0.3 on 2018-06-26 09:32 from django.conf import settings from django.db import migrations, models import django.db.models.deletion -import jobboard.models class Migration(migrations.Migration): @@ -11,7 +10,6 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('account', '0004_auto_20170416_1821'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] @@ -44,15 +42,6 @@ class Migration(migrations.Migration): ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], ), - migrations.CreateModel( - name='InviteCode', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('code', models.CharField(default=jobboard.models.random_string, max_length=32, unique=True, verbose_name='code')), - ('expired', models.BooleanField(default=False)), - ('signup_code', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='account.SignupCode')), - ], - ), migrations.CreateModel( name='Keyword', fields=[ diff --git a/quiz/tasks.py b/quiz/tasks.py index fc8919d..77ec872 100644 --- a/quiz/tasks.py +++ b/quiz/tasks.py @@ -81,6 +81,7 @@ def __init__(self): self.corrector.LoadLangModel('en.bin') def run(self): + if not self.candidate_sentence or not self.right_sentence: return False self.get_similarity_euql() @@ -95,7 +96,10 @@ def set_answers(self, right_answer, candidate_answer): def get_similarity_euql(self): for i in self.right_sentence: - first_vector = requests.post(self.api_url, data={"word": i}).text + try: + first_vector = requests.post(self.api_url, data={"word": i}, timeout=5).text + except Exception: + return 0.01 try: first_vector = np.asarray(eval(first_vector), dtype=np.float32) except SyntaxError: