Skip to content

Repeated subjects blocks are not merged during parsing into a single @id object #8

Description

@thenonameguy

Property Aggregation Issue: Multiple Statements for Same Subject Create Separate Nodes

Problem

When the same subject appears in multiple separate Turtle statements, @frogcat/ttl2jsonld creates separate JSON-LD nodes instead of aggregating properties into a single node.

Expected Behavior

Both scenarios should produce a single JSON-LD node with all properties aggregated.

Actual Behavior

Multiple statements create separate nodes, requiring manual property merging.

Minimal Reproduction (9 lines)

import pkg from '@frogcat/ttl2jsonld';
const { parse } = pkg;

// WORKING: Single block = 1 node with all properties
const single = `@prefix : <https://ex.com/> . :r :name "test" ; :desc "desc" .`;
const singleResult = parse(single);
console.log('Single block nodes:', (singleResult['@graph'] || [singleResult]).length); // 1

// BROKEN: Multiple statements = multiple nodes, properties scattered
const multiple = `@prefix : <https://ex.com/> . :r :name "test" . :r :desc "desc" .`;
const multipleResult = parse(multiple);
console.log('Multiple statements nodes:', multipleResult['@graph'].length); // 2 (should be 1)

Output:

Single block nodes: 1
Multiple statements nodes: 2

Impact

This forces consumers to implement manual node merging logic for fragmented Turtle data, which is common in SPARQL CONSTRUCT query results.

Version

@frogcat/ttl2jsonld@0.0.10

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions