Skip to content

Commit

Permalink
Merge pull request #888 from AI4Bharat/ocr_anlytics_charts
Browse files Browse the repository at this point in the history
added ocr charts for task and meta analytics
  • Loading branch information
ishvindersethi22 authored Jan 10, 2024
2 parents c8f8ba1 + d30218d commit 7c529fb
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 15 deletions.
4 changes: 4 additions & 0 deletions src/redux/reducers/Progress/MetaAnalytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const diffAnnotationReview = (payload) => {
review_audio_word_count: (value?.rev_audio_word_count),
diff_annotation_review_audio_word: (value?.ann_audio_word_count - value?.rev_audio_word_count),

ann_ocr_cumulative_word_count: (value?.ann_ocr_cumulative_word_count),
rew_ocr_cumulative_word_count: (value?.rew_ocr_cumulative_word_count),
diff_annotation_review_ocr_word: (value?.ann_ocr_cumulative_word_count - value?.rew_ocr_cumulative_word_count),

annotation_raw_aud_duration:(value?.ann_raw_aud_duration),
review_raw_aud_duration:(value?.rew_raw_aud_duration),
annotation_raw_aud_duration_tohour:(value?.ann_raw_aud_duration?.split(':')?.map(Number)?.[0] * 1 + value?.ann_raw_aud_duration?.split(':')?.map(Number)?.[1]/ 60 + value?.ann_raw_aud_duration?.split(':')?.map(Number)?.[2]/3600),
Expand Down
4 changes: 4 additions & 0 deletions src/redux/reducers/WorkspaceDetails/GetMetaAnalytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const diffAnnotationReview = (payload) => {
review_audio_word_count: (value?.rev_audio_word_count),
diff_annotation_review_audio_word: (value?.ann_audio_word_count - value?.rev_audio_word_count),

ann_ocr_cumulative_word_count: (value?.ann_ocr_cumulative_word_count),
rew_ocr_cumulative_word_count: (value?.rew_ocr_cumulative_word_count),
diff_annotation_review_ocr_word: (value?.ann_ocr_cumulative_word_count - value?.rew_ocr_cumulative_word_count),

annotation_raw_aud_duration:(value?.ann_raw_aud_duration),
review_raw_aud_duration:(value?.rew_raw_aud_duration),
annotation_raw_aud_duration_tohour:(value?.ann_raw_aud_duration?.split(':')?.map(Number)?.[0] * 1 + value?.ann_raw_aud_duration?.split(':')?.map(Number)?.[1]/ 60 + value?.ann_raw_aud_duration?.split(':')?.map(Number)?.[2]/3600),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ export default function MetaAnalytics(props) {
return <Grid key={_index} style={{marginTop:"15px"}}>
<WordCountMetaAnalyticsChart analyticsData={analyticsData}/>
{analyticsData[0].projectType.includes("Conversation") && <SentanceCountMetaAnalyticsChart analyticsData={analyticsData}/>}
</Grid>
}
</Grid>}
if (analyticsData.length && ocrProjectTypes.includes(analyticsData[0].projectType)){
return (<Grid key={_index} style={{marginTop:"15px"}}>
<WordCountMetaAnalyticsChart analyticsData={analyticsData} graphCategory='ocrWordCount'/>
</Grid>)}
})
:''}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function WordCountMetaAnalyticsChart(props) {
analyticsData?.sort(
(a, b) =>
b.annotation_audio_word_count -
a.review_audio_word_count
a.annotation_audio_word_count
);
setData(analyticsData);
let allAnnotatorAudioWordCount = 0;
Expand All @@ -45,6 +45,30 @@ export default function WordCountMetaAnalyticsChart(props) {
allAnnotatorAudioWordCount + allReviewAudioWordCount
);
}
else if (graphCategory=="ocrWordCount"){
analyticsData?.sort(
(a, b) =>
b.ann_ocr_cumulative_word_count -
a.ann_ocr_cumulative_word_count
);

setData(analyticsData);
let allAnnotatorCumulativeWordCount = 0;
let allReviewCumulativeWordCount = 0;
var languages;
analyticsData?.map((element, index) => {
allAnnotatorCumulativeWordCount +=
element.ann_ocr_cumulative_word_count;
allReviewCumulativeWordCount += element.rew_ocr_cumulative_word_count;
languages = element.languages;
});

setTotalAnnotationWordCount(allAnnotatorCumulativeWordCount);
setTotalReviewWordCount(allReviewCumulativeWordCount);
setTotalWordCount(
allAnnotatorCumulativeWordCount + allReviewCumulativeWordCount
);
}
else{
analyticsData?.sort(
(a, b) =>
Expand Down Expand Up @@ -103,7 +127,34 @@ export default function WordCountMetaAnalyticsChart(props) {
</p>
</p>
:
<p style={{ fontWeight: "normal" }}>
graphCategory=="ocrWordCount"?(<p style={{ fontWeight: "normal" }}>
{`Total count : ${
payload[0].payload.ann_ocr_cumulative_word_count
? new Intl.NumberFormat("en").format(
payload[0].payload.ann_ocr_cumulative_word_count
)
: 0
}`}
<p style={{ color: "rgba(243, 156, 18 )" }}>
{`Annotation : ${
payload[0].payload.diff_annotation_review_ocr_word
? new Intl.NumberFormat("en").format(
payload[0].payload.diff_annotation_review_ocr_word
)
: 0
}`}
<p style={{ color: "rgba(35, 155, 86 )" }}>{`Review : ${
payload[0].payload.rew_ocr_cumulative_word_count
? new Intl.NumberFormat("en").format(
payload[0].payload.rew_ocr_cumulative_word_count
)
: 0
}`}
</p>
</p>
</p>)
:
(<p style={{ fontWeight: "normal" }}>
{`Total count : ${
payload[0].payload.annotation_cumulative_word_count
? new Intl.NumberFormat("en").format(
Expand All @@ -125,9 +176,11 @@ export default function WordCountMetaAnalyticsChart(props) {
payload[0].payload.review_cumulative_word_count
)
: 0
}`}</p>
}`}
</p>
</p>
</p>}
</p>)
}
</p>
</div>
);
Expand All @@ -154,7 +207,7 @@ export default function WordCountMetaAnalyticsChart(props) {
padding: "16px 0",
}}
>
word Count Dashboard
Word Count Dashboard
</Typography>
</Box>
<Box className={classes.topBarInnerBox}>
Expand Down Expand Up @@ -247,15 +300,15 @@ export default function WordCountMetaAnalyticsChart(props) {
/>
<Legend verticalAlign="top" />
<Bar
dataKey={graphCategory=='audioWordCount'?"review_audio_word_count":"review_cumulative_word_count"}
dataKey={graphCategory=='audioWordCount'?"review_audio_word_count":graphCategory=="ocrWordCount"?"rew_ocr_cumulative_word_count":"review_cumulative_word_count"}
barSize={30}
name="Review"
stackId="a"
fill="rgba(35, 155, 86 )"
cursor="pointer"
/>
<Bar
dataKey={graphCategory=='audioWordCount'?"diff_annotation_review_audio_word":"diff_annotation_review"}
dataKey={graphCategory=='audioWordCount'?"diff_annotation_review_audio_word":graphCategory=="ocrWordCount"?"diff_annotation_review_ocr_word":"diff_annotation_review"}
barSize={30}
name="Annotation"
stackId="a"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ const TaskAnalytics = (props) => {
</Grid>)}
if(analyticsData.length &&
(translationProjectTypes.includes(analyticsData[0].projectType) ||
conversationProjectTypes.includes(analyticsData[0].projectType)
conversationProjectTypes.includes(analyticsData[0].projectType) ||
(ocrProjectTypes.includes(analyticsData[0].projectType))
)
){
return <Grid key={_index} style={{marginTop:"15px"}}>
<TaskCountAnalyticsChart analyticsData={analyticsData}/>
</Grid>
}
</Grid>}
})
:''}
</>
Expand Down
7 changes: 5 additions & 2 deletions src/ui/pages/container/Progress/Workspace/MetaAnalytics.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ export default function MetaAnalytics(props) {
return <Grid key={_index} style={{marginTop:"15px"}}>
<WordCountMetaAnalyticsChart analyticsData={analyticsData}/>
{analyticsData[0].projectType.includes("Conversation") && <SentanceCountMetaAnalyticsChart analyticsData={analyticsData}/>}
</Grid>
}
</Grid>}
if (analyticsData.length && ocrProjectTypes.includes(analyticsData[0].projectType)){
return (<Grid key={_index} style={{marginTop:"15px"}}>
<WordCountMetaAnalyticsChart analyticsData={analyticsData} graphCategory='ocrWordCount'/>
</Grid>)}
})
:''
}
Expand Down
3 changes: 2 additions & 1 deletion src/ui/pages/container/Progress/Workspace/TaskAnalytics.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ const TaskAnalytics = () => {
</Grid>)}
if(analyticsData.length &&
(translationProjectTypes.includes(analyticsData[0].projectType) ||
conversationProjectTypes.includes(analyticsData[0].projectType)
conversationProjectTypes.includes(analyticsData[0].projectType) ||
(ocrProjectTypes.includes(analyticsData[0].projectType))
)
){
return <Grid key={_index} style={{marginTop:"15px"}}>
Expand Down

0 comments on commit 7c529fb

Please sign in to comment.