Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/json export #778

Closed
wants to merge 8 commits into from
Prev Previous commit
add docstring for functions in JSONPainter
  • Loading branch information
cgill95 committed Jun 17, 2020
commit 397e5e5d8bdc178c9dc81bce3f5b87af62cbf6c9
10 changes: 10 additions & 0 deletions app/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,11 @@ def render(self, data, accepted_media_type=None, renderer_context=None):
class JSONPainter(object):

def paint(self, documents, export_format='jsonl'):
""" Paint the text and annotations for dataset export.

arguments:
export_format - distinguishes between jsonl and json formats, default is jsonl.
"""
serializer = DocumentSerializer(documents, many=True)
data = []
if export_format == 'json':
Expand All @@ -473,6 +478,11 @@ def paint(self, documents, export_format='jsonl'):

@staticmethod
def paint_labels(documents, labels, export_format='jsonl'):
""" Paint the labels for dataset export.

arguments:
export_format - distinguishes between jsonl and json formats, default is jsonl.
"""
serializer_labels = LabelSerializer(labels, many=True)
serializer = DocumentSerializer(documents, many=True)
data = []
Expand Down