Filter dummy errors
This commit is contained in:
parent
3a2712aeff
commit
6c2af753df
15
backend/requirements.txt
Normal file
15
backend/requirements.txt
Normal file
@ -0,0 +1,15 @@
|
||||
asgiref==3.5.2
|
||||
backports.zoneinfo==0.2.1
|
||||
defusedxml==0.7.1
|
||||
Django==4.0.4
|
||||
django-cors-headers==3.12.0
|
||||
django-environ==0.8.1
|
||||
djangorestframework==3.13.1
|
||||
djangorestframework-xml==2.0.0
|
||||
langdetect==1.0.9
|
||||
lxml==4.8.0
|
||||
pytz==2022.1
|
||||
regex==2022.4.24
|
||||
six==1.16.0
|
||||
sqlparse==0.4.2
|
||||
websocket-client==1.3.2
|
@ -11,12 +11,27 @@ from pathlib import Path
|
||||
import regex as re
|
||||
import uuid
|
||||
import os
|
||||
from langdetect import detect
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent
|
||||
|
||||
from rest_framework.decorators import api_view, renderer_classes, parser_classes
|
||||
from .renderers import MyXMLRenderer
|
||||
|
||||
def filter_dummy_errors(original, error):
|
||||
|
||||
if '//' in error:
|
||||
return (False, "")
|
||||
elif error.split(" ") > 2:
|
||||
return (False, "")
|
||||
# Check if is not english
|
||||
elif detect(error) != 'pl':
|
||||
return (False, "")
|
||||
|
||||
return (True, error)
|
||||
|
||||
|
||||
|
||||
def get_context(line, start_index, end_index):
|
||||
|
||||
start_index = start_index - 20
|
||||
@ -46,7 +61,9 @@ def diff_text(original, corrected):
|
||||
start_position = re.search('\[-([^\[]*?)\+}', line).start()
|
||||
end_position = re.search('\[-([^\[]*?)\+}', line).end()
|
||||
|
||||
is_error, error = filter_dummy_errors(removed, added)
|
||||
|
||||
if is_error:
|
||||
output.append({'id': 'grammar-error', 'type': 'grammar', 'correction': added[0], 'context': f'{get_context(lines[idx], start_position, end_position)}', 'msg': f"Zamiana '{removed[0]}' na '{added[0]}'"})
|
||||
|
||||
removed = re.findall('\[\-(.*?)\-]', new_line)
|
||||
|
Loading…
Reference in New Issue
Block a user