22 * API calls for fetching evaluation metrics and downloading them as a zip report.
33 */
44
5- // --- api ---
6- import * as Utils from "@/api/utils"
7- import type { BlobResponse } from "@/api/utils"
5+ import axios , { type AxiosResponse } from "axios"
6+ import { getBlob , type BlobResponse } from "@/api/utils"
87import type { UUID } from "@/types/corpora"
98import type {
109 ConfusionWrapper ,
1110 DistributionWrapper ,
1211 Metrics ,
1312 TermComparison ,
1413} from "@/types/evaluation"
15- // --- libraries ---
16- import axios from "axios"
17- // --- types ---
18- import type { AxiosResponse } from "axios"
1914
2015type ConfusionResponse = AxiosResponse < ConfusionWrapper >
2116type DistributionResponse = AxiosResponse < DistributionWrapper >
2217type MetricsResponse = AxiosResponse < Metrics >
2318
24- // --- computed ---
25- const evaluationPath = ( corpus : UUID , hypothesis : string ) =>
19+ const evaluationPath = ( corpus : UUID , hypothesis : string ) : string =>
2620 `/corpora/${ corpus } /jobs/${ hypothesis } /evaluation`
27- const confusionPath = ( corpus : UUID , hypothesis : string ) =>
21+ const confusionPath = ( corpus : UUID , hypothesis : string ) : string =>
2822 `${ evaluationPath ( corpus , hypothesis ) } /confusion`
29- const confusionSamplesPath = ( corpus : UUID , hypo : string ) =>
30- `${ evaluationPath ( corpus , hypo ) } /confusion /download`
31- const distributionPath = ( corpus : UUID , hypothesis : string ) =>
23+ const confusionSamplesPath = ( corpus : UUID , hypo : string ) : string =>
24+ `${ confusionPath ( corpus , hypo ) } /download`
25+ const distributionPath = ( corpus : UUID , hypothesis : string ) : string =>
3226 `${ evaluationPath ( corpus , hypothesis ) } /distribution`
33- const metricsPath = ( corpus : UUID , hypothesis : string ) =>
27+ const metricsPath = ( corpus : UUID , hypothesis : string ) : string =>
3428 `${ evaluationPath ( corpus , hypothesis ) } /metrics`
35- const metricsSamplesPath = ( corpus : UUID , hypo : string ) =>
36- `${ evaluationPath ( corpus , hypo ) } /metrics /download`
37- const downloadPath = ( corpus : UUID , hypothesis : string ) =>
29+ const metricsSamplesPath = ( corpus : UUID , hypo : string ) : string =>
30+ `${ metricsPath ( corpus , hypo ) } /download`
31+ const downloadPath = ( corpus : UUID , hypothesis : string ) : string =>
3832 `${ evaluationPath ( corpus , hypothesis ) } /download`
3933const documentLayerComparisonPath = (
4034 corpus : UUID ,
4135 job : string ,
4236 document : string ,
43- ) => `/corpora/${ corpus } /jobs/${ job } /documents/${ document } /evaluation`
37+ ) : string => `/corpora/${ corpus } /jobs/${ job } /documents/${ document } /evaluation`
4438
45- // --- methods ---
4639/**
4740 * Fetch term frequency distribution.
4841 * @param corpus UUID of the corpus.
@@ -96,7 +89,7 @@ export function getDownloadEvaluation(
9689 hypothesis : string ,
9790 reference : string ,
9891) : Promise < BlobResponse > {
99- return Utils . getBlob ( downloadPath ( corpus , hypothesis ) , {
92+ return getBlob ( downloadPath ( corpus , hypothesis ) , {
10093 params : { reference } ,
10194 } )
10295}
@@ -117,7 +110,7 @@ export function getConfusionSamples(
117110 refFilter : string ,
118111 annotationType : string ,
119112) : Promise < BlobResponse > {
120- return Utils . getBlob ( confusionSamplesPath ( corpus , hypothesis ) , {
113+ return getBlob ( confusionSamplesPath ( corpus , hypothesis ) , {
121114 params : { reference, hypoFilter, refFilter, annotationType } ,
122115 } )
123116}
@@ -147,7 +140,7 @@ export function getMetricsSamples(
147140 if ( group ) {
148141 params . group = group
149142 }
150- return Utils . getBlob ( metricsSamplesPath ( corpus , hypothesis ) , { params } )
143+ return getBlob ( metricsSamplesPath ( corpus , hypothesis ) , { params } )
151144}
152145
153146/**
0 commit comments