partition.ts (880B)
1 export type ClassifiedPartition = 2 | 'focused_food_availability' 3 | 'operational_listing' 4 | 'generic_nip99' 5 | 'ambiguous'; 6 // Raw tag-name presence counts even when a marker has no value. 7 // This pure classifier alone makes no event-verification or admission claim. 8 export function markerPartition( 9 tags: readonly (readonly string[])[] 10 ): ClassifiedPartition { 11 let focused = false; 12 let operational = false; 13 for (const tag of tags) { 14 if (tag[0] === 'radroots:price_unit' || tag[0] === 'radroots:quantity') 15 focused = true; 16 if ( 17 tag[0] === 'radroots:primary_bin' || 18 tag[0] === 'radroots:bin' || 19 tag[0] === 'radroots:price' 20 ) 21 operational = true; 22 if (focused && operational) return 'ambiguous'; 23 } 24 return focused 25 ? 'focused_food_availability' 26 : operational 27 ? 'operational_listing' 28 : 'generic_nip99'; 29 }