Skip to content

Commit

Permalink
Merge pull request #20 from nlpsandbox/update-to-0.2.2
Browse files Browse the repository at this point in the history
Update to API version 0.2.2
  • Loading branch information
tschaffter authored Nov 26, 2020
2 parents 7b2a23b + 108ccde commit ccfb5cc
Show file tree
Hide file tree
Showing 15 changed files with 209 additions and 152 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.idea
venv
venv
dist.yaml
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "person-name-annotator-example",
"version": "0.2.1",
"version": "0.2.2",
"license": "Apache-2.0",
"devDependencies": {
"@openapitools/openapi-generator-cli": "^1.0.18-4.3.1"
Expand Down
2 changes: 1 addition & 1 deletion server/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ openapi_server/models/note.py
openapi_server/models/service.py
openapi_server/models/text_annotation.py
openapi_server/models/text_person_name_annotation.py
openapi_server/models/text_person_name_annotation_request.py
openapi_server/models/text_person_name_annotations.py
openapi_server/openapi/openapi.yaml
openapi_server/test/__init__.py
openapi_server/test/test_service_controller.py
openapi_server/test/test_text_person_name_annotation_controller.py
openapi_server/typing_utils.py
openapi_server/util.py
4 changes: 2 additions & 2 deletions server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN apt-get update -qq -y \
# Copy server files
COPY data ${APP_DIR}/data
COPY openapi_server ${APP_DIR}/openapi_server
COPY requirements.txt app.ini ${APP_DIR}/
COPY requirements.txt uwsgi.ini ${APP_DIR}/
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh

Expand All @@ -32,4 +32,4 @@ EXPOSE 8080

# Set the entrypoint script and the default command run by the container
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["uwsgi", "--ini", "app.ini", "--lazy", "--http-socket", ":8080"]
CMD ["uwsgi", "--ini", "uwsgi.ini", "--lazy", "--http-socket", ":8080"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import re

from openapi_server.models.error import Error # noqa: E501
from openapi_server.models.note import Note # noqa: E501
from openapi_server.models.text_person_name_annotation_request import TextPersonNameAnnotationRequest # noqa: E501
from openapi_server.models.text_person_name_annotation import TextPersonNameAnnotation # noqa: E501
from openapi_server.models.text_person_name_annotations import TextPersonNameAnnotations # noqa: E501


Expand Down Expand Up @@ -36,26 +37,29 @@ def create_text_person_name_annotations(note=None): # noqa: E501
status = None
if connexion.request.is_json:
try:
note = Note.from_dict(connexion.request.get_json()) # noqa: E501
annotation_request = TextPersonNameAnnotationRequest.from_dict(connexion.request.get_json()) # noqa: E501
note = annotation_request._note # noqa: E501
annotations = []
for name in data._firstnames:
matches = re.finditer(
r'\b({})\b'.format(name), note._text, re.IGNORECASE)
for match in matches:
annotations.append({
'start': match.start(),
'length': len(match[0]),
'text': match[0]
})
annotations.append(TextPersonNameAnnotation(
start=match.start(),
length=len(match[0]),
text=match[0],
confidence=95
))
for name in data._lastnames:
matches = re.finditer(
r'\b({})\b'.format(name), note._text, re.IGNORECASE)
for match in matches:
annotations.append({
'start': match.start(),
'length': len(match[0]),
'text': match[0]
})
annotations.append(TextPersonNameAnnotation(
start=match.start(),
length=len(match[0]),
text=match[0],
confidence=95
))

res = TextPersonNameAnnotations(annotations)
status = 200
Expand Down
1 change: 1 addition & 0 deletions server/openapi_server/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
from openapi_server.models.service import Service
from openapi_server.models.text_annotation import TextAnnotation
from openapi_server.models.text_person_name_annotation import TextPersonNameAnnotation
from openapi_server.models.text_person_name_annotation_request import TextPersonNameAnnotationRequest
from openapi_server.models.text_person_name_annotations import TextPersonNameAnnotations
100 changes: 0 additions & 100 deletions server/openapi_server/models/note_all_of.py

This file was deleted.

38 changes: 35 additions & 3 deletions server/openapi_server/models/text_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TextAnnotation(Model):
Do not edit the class manually.
"""

def __init__(self, start=None, length=None, text=None): # noqa: E501
def __init__(self, start=None, length=None, text=None, confidence=None): # noqa: E501
"""TextAnnotation - a model defined in OpenAPI
:param start: The start of this TextAnnotation. # noqa: E501
Expand All @@ -24,22 +24,27 @@ def __init__(self, start=None, length=None, text=None): # noqa: E501
:type length: int
:param text: The text of this TextAnnotation. # noqa: E501
:type text: str
:param confidence: The confidence of this TextAnnotation. # noqa: E501
:type confidence: float
"""
self.openapi_types = {
'start': int,
'length': int,
'text': str
'text': str,
'confidence': float
}

self.attribute_map = {
'start': 'start',
'length': 'length',
'text': 'text'
'text': 'text',
'confidence': 'confidence'
}

self._start = start
self._length = length
self._text = text
self._confidence = confidence

@classmethod
def from_dict(cls, dikt) -> 'TextAnnotation':
Expand Down Expand Up @@ -124,3 +129,30 @@ def text(self, text):
"""

self._text = text

@property
def confidence(self):
"""Gets the confidence of this TextAnnotation.
The confidence in the accuracy of the annotation # noqa: E501
:return: The confidence of this TextAnnotation.
:rtype: float
"""
return self._confidence

@confidence.setter
def confidence(self, confidence):
"""Sets the confidence of this TextAnnotation.
The confidence in the accuracy of the annotation # noqa: E501
:param confidence: The confidence of this TextAnnotation.
:type confidence: float
"""
if confidence is not None and confidence > 100: # noqa: E501
raise ValueError("Invalid value for `confidence`, must be a value less than or equal to `100`") # noqa: E501
if confidence is not None and confidence < 0: # noqa: E501
raise ValueError("Invalid value for `confidence`, must be a value greater than or equal to `0`") # noqa: E501

self._confidence = confidence
38 changes: 35 additions & 3 deletions server/openapi_server/models/text_person_name_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TextPersonNameAnnotation(Model):
Do not edit the class manually.
"""

def __init__(self, start=None, length=None, text=None): # noqa: E501
def __init__(self, start=None, length=None, text=None, confidence=None): # noqa: E501
"""TextPersonNameAnnotation - a model defined in OpenAPI
:param start: The start of this TextPersonNameAnnotation. # noqa: E501
Expand All @@ -26,22 +26,27 @@ def __init__(self, start=None, length=None, text=None): # noqa: E501
:type length: int
:param text: The text of this TextPersonNameAnnotation. # noqa: E501
:type text: str
:param confidence: The confidence of this TextPersonNameAnnotation. # noqa: E501
:type confidence: float
"""
self.openapi_types = {
'start': int,
'length': int,
'text': str
'text': str,
'confidence': float
}

self.attribute_map = {
'start': 'start',
'length': 'length',
'text': 'text'
'text': 'text',
'confidence': 'confidence'
}

self._start = start
self._length = length
self._text = text
self._confidence = confidence

@classmethod
def from_dict(cls, dikt) -> 'TextPersonNameAnnotation':
Expand Down Expand Up @@ -126,3 +131,30 @@ def text(self, text):
"""

self._text = text

@property
def confidence(self):
"""Gets the confidence of this TextPersonNameAnnotation.
The confidence in the accuracy of the annotation # noqa: E501
:return: The confidence of this TextPersonNameAnnotation.
:rtype: float
"""
return self._confidence

@confidence.setter
def confidence(self, confidence):
"""Sets the confidence of this TextPersonNameAnnotation.
The confidence in the accuracy of the annotation # noqa: E501
:param confidence: The confidence of this TextPersonNameAnnotation.
:type confidence: float
"""
if confidence is not None and confidence > 100: # noqa: E501
raise ValueError("Invalid value for `confidence`, must be a value less than or equal to `100`") # noqa: E501
if confidence is not None and confidence < 0: # noqa: E501
raise ValueError("Invalid value for `confidence`, must be a value greater than or equal to `0`") # noqa: E501

self._confidence = confidence
Loading

0 comments on commit ccfb5cc

Please sign in to comment.