diff --git a/.environment-dev b/.environment-dev index 10c11edaa89b2b87e0bd615a78637896240248f1..99f45b908c1752d6b12c3c55a1b0a595582e4d78 100644 --- a/.environment-dev +++ b/.environment-dev @@ -15,4 +15,5 @@ EMAIL_USE_SSL=false SECRET_KEY=Ixosoh1iemoh0Heloh1thee5akooboonu5veehae4aikoh2ohg UWSGI_PROCESS_PER_CONTAINER=4 SERVER_HOST_NAME=valunifier.ipipan.waw.pl +#SERVER_HOST_NAME=localhost UNIFIED_FRAME_SERVICE_URL=http://walentygroupies.ipipan.waw.pl/ajax/clusterer/?unifier_frame_id= diff --git a/importer/unification/UnifiedFrameImport.py b/importer/unification/UnifiedFrameImport.py index e8c4dd45f1d03671b84b133c34ba96e5d5957a20..f1e392d34b82d4e61ddf743273922e805c7efd6f 100644 --- a/importer/unification/UnifiedFrameImport.py +++ b/importer/unification/UnifiedFrameImport.py @@ -5,7 +5,7 @@ from importer.Argument import SemanticRole from semantics.models import FrameOpinion import semantics.models from unifier.models import UnifiedFrameArgument, UnifiedFrame, UnifiedFrame2SlowalFrameMapping, \ - UnifiedFrameArgumentSlowalFrameMapping + UnifiedFrameArgumentSlowalFrameMapping, Frame class UnifiedFrameImport: @@ -54,14 +54,18 @@ class UnifiedFrameImport: def storeSlowalFrame(cls, tree, unifiedFrame, argumentIdsMapping): slowal_frame_id = tree._attrs['id'] + users = Frame.objects.filter(pk=slowal_frame_id) + if not users.exists(): + print('Slowal frame do not exists in database: {}', slowal_frame_id) + unifiedFrame2SlowalFrameMapping = UnifiedFrame2SlowalFrameMapping(unified_frame=unifiedFrame, slowal_frame_id=slowal_frame_id) unifiedFrame2SlowalFrameMapping.save() for subtree in tree._children: - if subtree._name == 'arguments_connections': + if subtree._name == 'argument_connections': for subsubtree in subtree._children: - if subsubtree._name == 'arguments_connection': + if subsubtree._name == 'argument_connection': unifier_argument_id = subsubtree._attrs['unifier_argument_id'] slowal_id = subsubtree._attrs['slowal_id'] unifiedFrameArgumentSlowalFrameMapping = UnifiedFrameArgumentSlowalFrameMapping(unified_frame_mapping=unifiedFrame2SlowalFrameMapping, diff --git a/phrase_expansions/management/commands/import_expansions.py b/phrase_expansions/management/commands/import_expansions.py index 85b3ca7cdf7430a2c1b4c072aaec2a9ec53a8117..5175a3293dc81c1dce574522099e41dd38055b9e 100644 --- a/phrase_expansions/management/commands/import_expansions.py +++ b/phrase_expansions/management/commands/import_expansions.py @@ -28,7 +28,7 @@ OPINION_MAP = { } def import_expansions(): - xml_file = os.path.join(BASE_DIR, 'data', 'walenty', 'phrase_types_expand_20210913.xml') + xml_file = os.path.join(BASE_DIR, 'data', 'walenty', 'phrase_types_expand_20230626.xml')#phrase_types_expand_20210913.xml') xml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), xml_file) parser = make_parser() diff --git a/syntax/management/commands/import_tei.py b/syntax/management/commands/import_tei.py index 01d65d00b0c3993e079ef4f279d8b6d56e07afa0..4f8faa2412da0b63c1d971a2238aa6f2549dea0e 100644 --- a/syntax/management/commands/import_tei.py +++ b/syntax/management/commands/import_tei.py @@ -211,7 +211,7 @@ def import_semantic_roles(): def import_semantic_role_types(): - role_types = [(10, u'role'), (20, u'alernative'), (30, u'modifier')] + role_types = [(10, u'role'), (20, u'alternative'), (30, u'modifier')] for pri, name in role_types: cont = RoleType(type=name) cont.save() diff --git a/unifier/views.py b/unifier/views.py index 57ddba4226e11f91a40823a64b200fb8272332ca..0a1114b77f16030d3d1f665f78291d017722f764 100644 --- a/unifier/views.py +++ b/unifier/views.py @@ -29,6 +29,10 @@ from django.db.models import Q from django.conf import settings import logging +from django.views.decorators.csrf import csrf_exempt + +import urllib3 + @ajax_required @transaction.atomic @@ -518,11 +522,16 @@ def change_unified_frame_status_to_verified_by_superleksykograf(request): return JsonResponse({}) +@csrf_exempt def create_unified_frame(frame_id): logging.info('Requesting unified frame creation service, frame_id: {}, service_url: {}'.format(frame_id, settings.UNIFIED_FRAME_SERVICE_URL )) - response = requests.post(settings.UNIFIED_FRAME_SERVICE_URL + str(frame_id), timeout=(1000, 1000)) + http = urllib3.PoolManager() + + r = http.request('GET', settings.UNIFIED_FRAME_SERVICE_URL + str(frame_id)) + + response = r.data.decode('utf-8') parser = make_parser() parser.setFeature(handler.feature_external_ges, False) @@ -530,7 +539,7 @@ def create_unified_frame(frame_id): unifiedFrameXMLHandler = UnificationPreprocessHandler() parser.setContentHandler(unifiedFrameXMLHandler) - f = io.StringIO(response.content.decode("utf-8")) + f = io.StringIO(response) parser.parse(f) @@ -565,10 +574,10 @@ def build_unified_frame_xml(request): slowal_frameElem = SubElement(connectionsElem, 'slowal_frame', attrib={'id': str(frame.id)}) - arguments_connectionsElem = SubElement(slowal_frameElem, 'arguments_connections') + arguments_connectionsElem = SubElement(slowal_frameElem, 'argument_connections') for id, argument in enumerate(arguments): - arguments_connectionElem = SubElement(arguments_connectionsElem, 'arguments_connection', + arguments_connectionElem = SubElement(arguments_connectionsElem, 'argument_connection', attrib={'unifier_argument_id': str(id), 'slowal_id': str(argument.id)}) xml = tostring(matchingElem)