@@ -49,6 +49,37 @@ const formatRecognitionResultSummary = (value: unknown) => {
4949 return parts . length > 0 ? parts . join ( ' | ' ) : formatDetailValue ( value , 240 )
5050}
5151
52+ const formatCount = ( value : unknown ) => Array . isArray ( value ) ? String ( value . length ) : '-'
53+
54+ const formatChildBestSummary = ( value : unknown ) => {
55+ if ( ! isRecord ( value ) ) return '-'
56+ const parts : string [ ] = [ ]
57+ if ( hasDetailValue ( value . text ) ) parts . push ( `text=${ value . text } ` )
58+ if ( hasDetailValue ( value . score ) ) parts . push ( `score=${ value . score } ` )
59+ if ( hasDetailValue ( value . count ) ) parts . push ( `count=${ value . count } ` )
60+ if ( hasDetailValue ( value . label ) ) parts . push ( `label=${ value . label } ` )
61+ if ( hasDetailValue ( value . cls_index ) ) parts . push ( `cls_index=${ value . cls_index } ` )
62+ if ( Array . isArray ( value . box ) && parts . length === 0 ) parts . push ( `box=[${ value . box . join ( ', ' ) } ]` )
63+ return parts . length > 0 ? parts . join ( ', ' ) : formatDetailValue ( value , 120 )
64+ }
65+
66+ const formatChildRecognitionSummary = ( item : Record < string , any > ) => {
67+ const hit = ! ! item . box
68+ const parts = [ `${ hit ? '命中' : '未命中' } ${ item . name ?? '-' } (${ item . algorithm ?? '-' } )` ]
69+
70+ if ( Array . isArray ( item . box ) ) {
71+ parts . push ( `box=[${ item . box . join ( ', ' ) } ]` )
72+ }
73+
74+ if ( isRecord ( item . detail ) ) {
75+ parts . push ( `all ${ formatCount ( item . detail . all ) } ` )
76+ parts . push ( `filtered ${ formatCount ( item . detail . filtered ) } ` )
77+ parts . push ( `best ${ formatChildBestSummary ( item . detail . best ) } ` )
78+ }
79+
80+ return parts . join ( ',' )
81+ }
82+
5283export const buildRecognitionDetailRows = (
5384 recognition : any ,
5485 descriptionColumns : number ,
@@ -62,19 +93,25 @@ export const buildRecognitionDetailRows = (
6293
6394 const detail = recognition . detail
6495 if ( Array . isArray ( detail ) ) {
65- const hitChildren = detail . filter ( ( item ) => isRecord ( item ) && item . box ) . length
96+ const childRecognitions = detail . filter ( isRecord )
97+ const hitChildren = childRecognitions . filter ( ( item ) => item . box ) . length
6698 rows . push (
67- { label : '子识别数量' , value : detail . length } ,
68- { label : '命中子识别数量' , value : hitChildren } ,
99+ {
100+ label : '整体判定' ,
101+ value : `${ recognition . box ? '命中' : '未命中' } (${ hitChildren } /${ detail . length } )` ,
102+ } ,
69103 )
70104
71- const children = detail
72- . filter ( isRecord )
105+ childRecognitions
106+ . sort ( ( left , right ) => Number ( ! ! left . box ) - Number ( ! ! right . box ) )
73107 . slice ( 0 , 8 )
74- . map ( ( item ) => `${ item . name ?? '-' } (${ item . algorithm ?? '-' } )${ item . box ? ` [${ item . box . join ( ', ' ) } ]` : '' } ` )
75- if ( children . length > 0 ) {
76- rows . push ( { label : '子识别列表' , value : children . join ( '\n' ) , span : descriptionColumns } )
77- }
108+ . forEach ( ( item , index ) => {
109+ rows . push ( {
110+ label : `子识别 ${ index + 1 } ` ,
111+ value : formatChildRecognitionSummary ( item ) ,
112+ span : descriptionColumns ,
113+ } )
114+ } )
78115 return rows
79116 }
80117
0 commit comments