Automated tool for extracting temporal information from documents and generating chronological timelines of events for legal proceedings and investigations.
pip install dateparser spacy plotly
python -m spacy download en_core_web_lg
from timeline_generator import TimelineGenerator
# Initialize
tg = TimelineGenerator()
# Process documents
timeline = tg.generate_from_documents([
'witness_statement_1.pdf',
'police_report.pdf',
'medical_records.pdf'
])
# Export timeline
timeline.to_html('case_timeline.html')
timeline.to_json('case_timeline.json')
timeline.to_csv('case_timeline.csv')
TimelineGenerator.generate_from_documents(document_list)
Processes multiple documents and creates a unified timeline.
Parameters:
document_list
(list): List of document paths to processReturns:
Timeline
object containing extracted eventsTimeline.to_html(output_path, interactive=True)
Exports timeline as interactive HTML visualization.
Timeline.to_json(output_path)
Exports timeline data as JSON.
Timeline.filter_by_date(start_date, end_date)
Filters timeline to specific date range.
{
"events": [
{
"date": "2024-03-15",
"time": "14:30",
"description": "Witness reported incident",
"source": "witness_statement_1.pdf",
"confidence": 0.95,
"entities": ["John Doe", "Location X"]
}
]
}
Create config.yaml
to customize:
timeline:
date_formats:
- "%Y-%m-%d"
- "%d/%m/%Y"
- "%B %d, %Y"
languages:
- en
- fr
- es
conflict_resolution: "most_recent"
min_confidence: 0.7
tg = TimelineGenerator()
timeline = tg.generate_from_text("""
On March 15, 2024, the incident was first reported.
Two days later, police arrived at the scene.
The investigation concluded on March 30, 2024.
""")
# Generate timeline
timeline = tg.generate_from_documents(documents)
# Filter to specific period
march_events = timeline.filter_by_date("2024-03-01", "2024-03-31")
# Filter by confidence
high_confidence = timeline.filter_by_confidence(min_confidence=0.9)
# Combine filters
filtered = timeline.filter(
start_date="2024-03-01",
end_date="2024-03-31",
min_confidence=0.8,
entities=["John Doe"]
)
The tool supports multiple visualization formats:
The tool handles various edge cases:
See main repository CONTRIBUTING.md for guidelines.
MIT License