Export Content with Entity Annotations
User Intent
"How do I export content with entity annotations? Show me export formats with entity metadata."
Operation
SDK Methods: getContent(), queryContents() for export
Format: JSON export with entity data
Use Case: Data export with entity annotations
Prerequisites
Content with extracted entities
Export destination (file, database)
Understanding of entity structure
Complete Code Example (TypeScript)
import { Graphlit } from 'graphlit-client';
import * as fs from 'fs';
const graphlit = new Graphlit();
// Get content with entities
const content = await graphlit.getContent('content-id');
// Prepare export data
const exportData = {
id: content.content.id,
name: content.content.name,
type: content.content.type,
creationDate: content.content.creationDate,
text: content.content.markdown,
entities: content.content.observations?.map(obs => ({
type: obs.type,
name: obs.observable.name,
id: obs.observable.id,
occurrences: obs.occurrences?.map(occ => ({
confidence: occ.confidence,
pageIndex: occ.pageIndex,
boundingBox: occ.boundingBox,
startTime: occ.startTime,
endTime: occ.endTime
}))
})) || []
};
// Export as JSON
fs.writeFileSync('export.json', JSON.stringify(exportData, null, 2));
console.log('Exported with entity annotations');
// Export as CSV (flattened)
const csvRows = [
['Entity Type', 'Entity Name', 'Confidence', 'Page', 'Document'].join(',')
];
content.content.observations?.forEach(obs => {
obs.occurrences?.forEach(occ => {
csvRows.push([
obs.type,
obs.observable.name,
occ.confidence.toFixed(2),
occ.pageIndex?.toString() || '',
content.content.name
].join(','));
});
});
fs.writeFileSync('export.csv', csvRows.join('\n'));
console.log('Exported as CSV');Export Formats
JSON (Full Fidelity)
Complete entity data with occurrences
CSV (Tabular)
Flattened for spreadsheet analysis
XML (Structured)
Hierarchical entity annotations
Database (Structured Storage)
PostgreSQL, MongoDB for querying
Use Cases
Data Analysis: Export for external tools Backup: Archive with entity data Integration: Feed to other systems Reporting: Generate entity reports Training Data: ML model training
Developer Hints
Include entity IDs for re-linking
Preserve occurrence data (timestamps, pages)
Export in batches for large datasets
Compress for large exports
Include metadata (dates, sources)
Last updated
Was this helpful?