@@ -104,6 +104,21 @@ export function IBMWatsonNLUResults( { postId } ) {
104104 keywords : responseData . keywords ,
105105 } ;
106106
107+ const hasAnyTags = Object . keys ( renderData ) . some (
108+ ( taxSlug ) => renderData [ taxSlug ] . length > 0
109+ ) ;
110+
111+ const allBelowThreshold =
112+ hasAnyTags &&
113+ Object . keys ( renderData ) . every ( ( taxSlug ) =>
114+ renderData [ taxSlug ] . every ( ( tag ) => {
115+ const threshold =
116+ settings [ `${ taxMap [ taxSlug ] } _threshold` ] ;
117+ const score = normalizeScore ( tag . score || tag . relevance ) ;
118+ return score < threshold ;
119+ } )
120+ ) ;
121+
107122 const card = Object . keys ( renderData ) . map ( ( taxSlug ) => {
108123 const tags = renderData [ taxSlug ] . map ( ( tag , _index ) => {
109124 const threshold = settings [ `${ taxMap [ taxSlug ] } _threshold` ] ;
@@ -112,7 +127,7 @@ export function IBMWatsonNLUResults( { postId } ) {
112127 const scoreClass =
113128 score >= threshold
114129 ? 'classifai__classification-previewer-result-tag--exceeds-threshold'
115- : '' ;
130+ : 'classifai__classification-previewer-result-tag--below-threshold ' ;
116131
117132 return (
118133 < div
@@ -179,6 +194,18 @@ export function IBMWatsonNLUResults( { postId } ) {
179194 'classifai'
180195 ) }
181196 </ Notice >
197+ { allBelowThreshold && (
198+ < Notice
199+ status = "warning"
200+ isDismissible = { false }
201+ className = "classifai__classification-previewer-result-notice"
202+ >
203+ { __ (
204+ 'None of the terms are above the configured threshold.' ,
205+ 'classifai'
206+ ) }
207+ </ Notice >
208+ ) }
182209 { card }
183210 </ >
184211 ) : null ;
0 commit comments