The confluence of information into intelligence - A DSL compiler that transforms qualitative research annotations into canonical knowledge structures
Project description
Synesis
The confluence of information into intelligence.
A Domain-Specific Language (DSL) compiler that transforms qualitative research annotations into canonical knowledge structures.
Philosophy
Human knowledge is naturally intricate, full of nuances and deep connections. This is complexity—and it is valuable. Complication arises only when we lack adequate methods for organizing knowledge.
Synesis is a declarative Domain-Specific Language created for those who need more than simple annotations. It is a method for knowledge consolidation.
Unlike traditional tools, Synesis acts as a compiler for your analytical thinking: it receives your interpretations and annotations in plain text files, validates their logical consistency, and transforms them into canonical, rigorous knowledge structures.
Many believe that technical rigor stifles creativity. Synesis proves otherwise: discipline is the true form of freedom. By delegating logical organization to a canonical structure, your mind is freed for what truly matters: interpretation, nuance, and insight.
The result is true σύνεσις (sýnesis): the convergence of information fragments into an intelligible, auditable, and technically structured whole.
What Synesis Does
- Formal syntax for annotating research sources with structured metadata
- Template-based validation ensuring consistency across annotations
- BibTeX integration for bibliographic reference management
- Semantic validation of codes, chains, ontologies, and field bundles
- Multiple export formats (JSON, CSV, Excel) for downstream analysis
- Comprehensive error reporting with precise source location tracking
Features
- LALR(1) Parser: Fast, deterministic parsing with Lark grammar
- Type-Safe AST: Full type hints throughout the codebase
- Pedagogical Error Messages: Clear, actionable error messages with suggestions
- Template System: Define custom field schemas with REQUIRED/OPTIONAL/FORBIDDEN constraints
- BUNDLE Validation: Enforce co-occurring field groups (e.g., note + chain pairs)
- Chain Semantics: Validate qualified chains (A -> INFLUENCES -> B) with relation types
- Ontology Support: Define hierarchical concept vocabularies with ORDERED/ENUMERATED types
- Source Traceability: Every AST node tracks file, line, and column location
Installation
From PyPI (Coming Soon)
pip install synesis
From TestPyPI
pip install -i https://test.pypi.org/simple/ synesis
From Source
git clone https://github.com/synesis-lang/synesis.git
cd synesis
pip install -e .
Quick Start
1. Create a Project File (project.synp)
PROJECT MyResearch
TEMPLATE "template.synt"
INCLUDE BIBLIOGRAPHY "references.bib"
INCLUDE ANNOTATIONS "annotations.syn"
INCLUDE ONTOLOGY "ontologies.syno"
DESCRIPTION
Climate Change Perception Study
END METADATA
END PROJECT
2. Define a Template (template.synt)
TEMPLATE QualitativeAnalysis
SOURCE FIELDS
REQUIRED date, country
OPTIONAL keywords
END SOURCE FIELDS
ITEM FIELDS
REQUIRED quote
REQUIRED BUNDLE note, chain
OPTIONAL tags
END ITEM FIELDS
ONTOLOGY FIELDS
REQUIRED description
OPTIONAL topic
END ONTOLOGY FIELDS
FIELD quote TYPE QUOTATION
SCOPE SOURCE
DESCRIPTION Extracted text from source
END FIELD
FIELD note TYPE MEMO
SCOPE ITEM
DESCRIPTION Analytical annotation
END FIELD
FIELD chain TYPE CHAIN
SCOPE ITEM
ARITY >= 2
RELATIONS
INFLUENCES: Causal influence relationship
ENABLES: Enabling relationship
END RELATIONS
END FIELD
3. Add Bibliography (references.bib)
@article{smith2024,
author = {Smith, John},
title = {Climate Beliefs and Policy Support},
year = {2024},
journal = {Environmental Research}
}
4. Create Annotations (annotations/sample.syn)
SOURCE @smith2024
date: 2024-03-15
country: United States
END SOURCE
ITEM @smith2024
quote: Public acceptance is crucial for climate policy implementation.
note: Identifies acceptance as key factor
chain: Public_Acceptance -> INFLUENCES -> Policy_Support
note: Links to economic barriers
chain: Policy_Support -> ENABLES -> Climate_Action
END ITEM
5. Define Ontology (ontologies/concepts.syno)
ONTOLOGY Public_Acceptance
description: Community-level support for climate policies
topic: Social_Factors
END ONTOLOGY
ONTOLOGY Policy_Support
description: Governmental and institutional backing
topic: Political_Factors
END ONTOLOGY
6. Compile the Project
# Validate syntax and semantics
synesis compile project.synp
# Export to JSON
synesis compile project.synp --json output.json
# Export to CSV
synesis compile project.synp --csv output_dir/
# Export to Excel
synesis compile project.synp --xls analysis.xlsx
CLI Commands
synesis compile
Compile a Synesis project and generate outputs.
synesis compile PROJECT.synp [OPTIONS]
Options:
--json PATH Export to JSON format
--csv PATH Export to CSV directory (creates multiple tables)
--xls PATH Export to Excel workbook
--force Generate outputs even with validation errors
--verbose Show detailed compilation progress
synesis check
Validate syntax of a single file without full compilation.
synesis check FILE.syn
synesis validate-template
Validate a template file structure.
synesis validate-template TEMPLATE.synt
synesis init
Initialize a new Synesis project with example files.
synesis init [PROJECT_NAME]
Python API
Use Synesis directly in Python scripts and Jupyter Notebooks without file I/O.
Quick Example
import synesis
result = synesis.load(
project_content='PROJECT Demo TEMPLATE "t.synt" END PROJECT',
template_content='''
TEMPLATE Demo
SOURCE FIELDS
OPTIONAL date
END SOURCE FIELDS
ITEM FIELDS
REQUIRED quote
END ITEM FIELDS
FIELD date TYPE DATE SCOPE SOURCE END FIELD
FIELD quote TYPE QUOTATION SCOPE ITEM END FIELD
END TEMPLATE
''',
annotation_contents={
"data.syn": '''
SOURCE @ref2024
date: 2024-01-15
ITEM
quote: Technology shows promising results.
END ITEM
END SOURCE
'''
},
bibliography_content='@article{ref2024, author={Silva}, year={2024}}'
)
if result.success:
# Export to pandas DataFrame
df = result.to_dataframe("items")
# Export to dict (JSON-serializable)
data = result.to_json_dict()
# Get all tables as DataFrames
dfs = result.to_dataframes()
Available Methods
| Method | Returns | Description |
|---|---|---|
to_dataframe(table) |
pd.DataFrame |
Single table as DataFrame |
to_dataframes() |
Dict[str, DataFrame] |
All tables as DataFrames |
to_json_dict() |
Dict |
Full JSON structure as dict |
to_csv_tables() |
Dict[str, tuple] |
Tables as (headers, rows) |
Output Formats
JSON Export
Hierarchical structure preserving SOURCE → ITEM relationships:
{
"project": {
"name": "MyResearch",
"template": "template.synt",
"metadata": {...}
},
"sources": [
{
"bibref": "smith2024",
"fields": {"date": "2024-03-15", "country": "United States"},
"items": [
{
"quote": "Public acceptance is crucial...",
"notes": ["Identifies acceptance as key factor"],
"chains": [
{
"nodes": ["Public_Acceptance", "INFLUENCES", "Policy_Support"],
"triples": [["Public_Acceptance", "INFLUENCES", "Policy_Support"]]
}
],
"source_file": "annotations/sample.syn",
"source_line": 7,
"source_column": 1
}
]
}
],
"ontologies": [...]
}
CSV Export
Generates separate tables with full traceability:
sources.csv: Bibliography entries with fieldsitems.csv: Annotated excerpts with metadatacodes.csv: All applied codes with frequencychains.csv: Relational triples (from, relation, to)ontologies.csv: Concept definitionstopics.csv: Hierarchical topic groupings
Each row includes source_file, source_line, source_column for traceability.
Excel Export
Multi-sheet workbook combining all tables with formatting.
Language Specification
Full language specification available at: https://synesis-lang.github.io/synesis-docs
Core Concepts
- PROJECT: Root container defining template and includes
- SOURCE: Contextualizes items with bibliographic reference
- ITEM: Analytical unit containing quote, codes, memos, chains
- ONTOLOGY: Concept definition with description and metadata
- TEMPLATE: Meta-schema defining field requirements and types
- FIELD: Type declaration (QUOTATION, MEMO, CODE, CHAIN, TEXT, DATE, SCALE, ENUMERATED, ORDERED, TOPIC)
Field Types
| Type | Scope | Description |
|---|---|---|
| QUOTATION | ITEM | Verbatim text excerpt from source |
| MEMO | ITEM | Researcher's analytical annotation |
| CODE | ITEM | Categorical label (concept reference) |
| CHAIN | ITEM | Qualified relational structure (A → REL → B) |
| TEXT | Any | Free-form text field |
| DATE | SOURCE | Temporal metadata |
| SCALE | Any | Numeric value with range constraints |
| ENUMERATED | Any | Closed-list categorical value |
| ORDERED | ONTOLOGY | Hierarchical indexed value |
| TOPIC | ONTOLOGY | Dynamic category grouping |
Development
Running Tests
# Install development dependencies
pip install -e ".[dev]"
# Run all tests
pytest
# Run with coverage
pytest --cov=synesis --cov-report=html
Project Structure
synesis/
├── synesis/ # Main package
│ ├── cli.py # Command-line interface
│ ├── compiler.py # Compilation orchestrator
│ ├── ast/ # AST node definitions
│ ├── parser/ # Parsing and loading
│ ├── semantic/ # Validation and linking
│ ├── exporters/ # Output format generators
│ └── grammar/ # Lark grammar file
└── tests/ # Test suite with fixtures
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Documentation
- Homepage: https://synesis-lang.github.io/synesis-docs
- Repository: https://github.com/synesis-lang/synesis
- Issue Tracker: https://github.com/synesis-lang/synesis/issues
License
This project is licensed under the MIT License - see the LICENSE file for details.
Citation
If you use Synesis in your research, please cite:
@software{synesis2026,
title = {Synesis: A Domain-Specific Language for Qualitative Research},
author = {{De Britto, Christian Maciel}},
year = {2026},
url = {https://github.com/synesis-lang/synesis},
version = {0.2.0}
}
Acknowledgments
Synesis implements a Result-based error handling system inspired by Elm and Rust, ensuring robust compilation without uncontrolled exceptions.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file synesis-0.2.1.tar.gz.
File metadata
- Download URL: synesis-0.2.1.tar.gz
- Upload date:
- Size: 94.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4612452c684d64dac0455f268f8559b2a7ea90c65581cc3e2d43b9a689477318
|
|
| MD5 |
188c8f9883b12037e77d80fa68be52d5
|
|
| BLAKE2b-256 |
51f9094ff3dbdbbdb660df6959c9417caf0577b5e10c1c842104e0a703b4997c
|
File details
Details for the file synesis-0.2.1-py3-none-any.whl.
File metadata
- Download URL: synesis-0.2.1-py3-none-any.whl
- Upload date:
- Size: 71.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f060730be4b79665e780fbe255b19f82421c88c324b30dd435678f149d6b4fea
|
|
| MD5 |
a0db589aec2ac723071bcc20dbb440f4
|
|
| BLAKE2b-256 |
aa5b9feb2249d9dcc7337ec31a38709f5c6eabb68870c2e4ad1dcc63c13e1498
|