예제 #1
0
    def test_entity_created(self):
        kind = EntityKindFactory()
        doc = IEDocFactory()
        offset = 0
        offset_end = 1

        entity_count = Entity.objects.all().count()
        EntityOccurrenceManager.create_with_entity(kind, doc, offset,
                                                   offset_end)
        new_entity_count = Entity.objects.all().count()
        self.assertEqual(new_entity_count, entity_count + 1)
예제 #2
0
파일: test_entity.py 프로젝트: 52nlp/iepy
    def test_segmenter_is_run(self):
        with mock.patch("iepy.preprocess.segmenter.SyntacticSegmenterRunner") as mock_segmenter:
            kind = EntityKindFactory()
            doc = IEDocFactory()
            offset = 0
            offset_end = 1

            EntityOccurrenceManager.create_with_entity(
                kind, doc, offset, offset_end
            )

            self.assertTrue(mock_segmenter.called)
예제 #3
0
파일: test_entity.py 프로젝트: 52nlp/iepy
    def test_entity_created(self):
        kind = EntityKindFactory()
        doc = IEDocFactory()
        offset = 0
        offset_end = 1

        entity_count = Entity.objects.all().count()
        EntityOccurrenceManager.create_with_entity(
            kind, doc, offset, offset_end
        )
        new_entity_count = Entity.objects.all().count()
        self.assertEqual(new_entity_count, entity_count + 1)
예제 #4
0
    def test_segmenter_is_run(self):
        with mock.patch("iepy.preprocess.segmenter.SyntacticSegmenterRunner"
                        ) as mock_segmenter:
            kind = EntityKindFactory()
            doc = IEDocFactory()
            offset = 0
            offset_end = 1

            EntityOccurrenceManager.create_with_entity(kind, doc, offset,
                                                       offset_end)

            self.assertTrue(mock_segmenter.called)
예제 #5
0
파일: views.py 프로젝트: 52nlp/iepy
def create_entity_occurrence(request):
    kind = get_object_or_404(EntityKind, id=request.POST.get("kind"))
    document = get_object_or_404(IEDocument, id=request.POST.get("doc_id"))

    if "offset" not in request.POST or "offset_end" not in request.POST:
        raise HttpResponseBadRequest("Invalid offsets")
    try:
        offset = int(request.POST["offset"])
        offset_end = int(request.POST["offset_end"])
    except ValueError:
        raise HttpResponseBadRequest("Invalid offsets")

    EntityOccurrenceManager.create_with_entity(kind, document, offset, offset_end)
    result = json.dumps({"success": True})
    return HttpResponse(result, content_type='application/json')
예제 #6
0
def create_entity_occurrence(request):
    kind = get_object_or_404(EntityKind, id=request.POST.get("kind"))
    document = get_object_or_404(IEDocument, id=request.POST.get("doc_id"))

    if "offset" not in request.POST or "offset_end" not in request.POST:
        raise HttpResponseBadRequest("Invalid offsets")
    try:
        offset = int(request.POST["offset"])
        offset_end = int(request.POST["offset_end"])
    except ValueError:
        raise HttpResponseBadRequest("Invalid offsets")

    EntityOccurrenceManager.create_with_entity(kind, document, offset,
                                               offset_end)
    result = json.dumps({"success": True})
    return HttpResponse(result, content_type='application/json')