-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:ekocbiyik/skyz
- Loading branch information
Showing
5 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from django.core.management.base import BaseCommand | ||
from skyz.models.model import TestDataTablosu | ||
from skyz.rest.bayes_search import BayesSearch | ||
|
||
class Command(BaseCommand): | ||
|
||
def handle(self, *args, **kwargs): | ||
objects = TestDataTablosu.objects.all() | ||
total_object_count = len(objects) | ||
succes_rate = 0 | ||
for test in objects: | ||
tmp = test.__dict__ | ||
response = BayesSearch().post_to_bayes(tmp['content']) | ||
if response == tmp['category']: | ||
succes_rate += 1 | ||
print(str(total_object_count)+"/"+str(succes_rate)) | ||
|
||
|
||
|
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from rest_framework.views import APIView | ||
from rest_framework.response import Response | ||
import requests | ||
import json | ||
|
||
|
||
class BayesSearch(APIView): | ||
bayes_backend_ip = 'http://127.0.0.1:6161/' | ||
bayes_api_path = 'api/classify' | ||
|
||
body = { | ||
"body": None | ||
} | ||
|
||
|
||
def post(self, request): | ||
category = self.post_to_bayes(self.request.data['context']) | ||
return Response(category) | ||
|
||
def post_to_bayes(self, content): | ||
self.body['body'] = content | ||
headers = {'content-type': 'application/json'} | ||
f = requests.post(url=self.bayes_backend_ip + self.bayes_api_path, data=json.dumps(self.body), headers=headers) | ||
content = json.loads(f.content) | ||
category = content['content'] | ||
return category |
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
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