mirror of
https://github.com/msitarzewski/agency-agents.git
synced 2026-10-10 12:45:05 +00:00
Merge #974: Preserve mixed and nested sequences in layout classification
This commit is contained in:
@@ -191,14 +191,22 @@ export class DataShapeClassifier {
|
||||
if (Array.isArray(data)) {
|
||||
if (data.length === 0) return 'leaf_item';
|
||||
|
||||
// Classify the whole sequence; a first-item guess can hide later content.
|
||||
// Mixed scalars/mappings and nested sequences need structural rendering.
|
||||
const allScalars = data.every(item => typeof item !== 'object' || item === null);
|
||||
const allMappings = data.every(item =>
|
||||
typeof item === 'object' && item !== null && !Array.isArray(item)
|
||||
);
|
||||
if (!allScalars && !allMappings) return 'block_group';
|
||||
|
||||
// Sequence of Scalars
|
||||
if (typeof data[0] !== 'object' || data[0] === null) {
|
||||
if (allScalars) {
|
||||
const avgLength = data.reduce((acc, str) => acc + String(str).length, 0) / data.length;
|
||||
return avgLength <= 35 ? 'badge_list' : 'prose_flow';
|
||||
}
|
||||
|
||||
// Sequence of Mappings
|
||||
const records = data.filter(item => typeof item === 'object' && item !== null);
|
||||
const records = data; // allMappings: every original item participates
|
||||
const uniformity = this.calculateJaccardUniformity(records);
|
||||
|
||||
if (uniformity >= 0.55) {
|
||||
|
||||
Reference in New Issue
Block a user