Skip to content

Commit

Permalink
Merge pull request #817 from AI4Bharat/small_fix
Browse files Browse the repository at this point in the history
Small fix
  • Loading branch information
ishvindersethi22 authored Aug 23, 2023
2 parents 5cf3659 + e2db1bc commit 2ba7d3c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
11 changes: 10 additions & 1 deletion backend/utils/convert_result_to_chitralekha_format.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
def create_memory(result):
memory = {}
for i in range(len(result)):
key = result[i]["id"]
try:
key = result[i]["id"]
except KeyError:
print(
f"The entry number {i} is not having an id hence cannot be converted to CL_format"
)
del result[i]
continue
if key not in memory:
memory[key] = {"labels_dict_idx": -1, "text_dict_idx": -1}
if result[i]["type"] == "labels":
Expand All @@ -12,6 +19,8 @@ def create_memory(result):


def convert_result_to_chitralekha_format(result, ann_id):
if len(result) == 1 and result[0] == {}:
return [{}]
memory = create_memory(result)
modified_result = []
count = 1
Expand Down
19 changes: 16 additions & 3 deletions backend/workspaces/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,9 @@ def project_analytics(self, request, pk=None):
for each_task in labeled_tasks:
try:
annotate_annotation = Annotation.objects.filter(
task=each_task, annotation_type=ANNOTATOR_ANNOTATION
task=each_task,
annotation_type=ANNOTATOR_ANNOTATION,
annotation_status__in=["labeled"],
)[0]
total_duration_annotated_count_list.append(
get_audio_transcription_duration(
Expand All @@ -1282,7 +1284,13 @@ def project_analytics(self, request, pk=None):
for each_task in reviewed_tasks:
try:
review_annotation = Annotation.objects.filter(
task=each_task, annotation_type=REVIEWER_ANNOTATION
task=each_task,
annotation_type=REVIEWER_ANNOTATION,
annotation_status__in=[
"accepted",
"accepted_with_minor_changes",
"accepted_with_major_changes",
],
)[0]
total_duration_reviewed_count_list.append(
get_audio_transcription_duration(
Expand Down Expand Up @@ -1311,7 +1319,12 @@ def project_analytics(self, request, pk=None):
for each_task in superchecked_tasks:
try:
supercheck_annotation = Annotation.objects.filter(
task=each_task, annotation_type=SUPER_CHECKER_ANNOTATION
task=each_task,
annotation_type=SUPER_CHECKER_ANNOTATION,
annotation_status__in=[
"validated",
"validated_with_changes",
],
)[0]
total_duration_superchecked_count_list.append(
get_audio_transcription_duration(
Expand Down

0 comments on commit 2ba7d3c

Please sign in to comment.