TextGrid
textgrid is a Rust crate for working with Praat .TextGrid files, providing parsing, writing, manipulation, and history tracking for TextGrid data. This library is designed for researchers, linguists, and developers working with phonetic annotations or time-aligned data, supporting both text (long/short) and binary formats as per Praat's specification.
Features
- Parsing and Writing: Read and write TextGrid files in long/short text formats and Praat's binary format.
- Manipulation: Add, remove, split, merge, and query tiers, intervals, and points with undo/redo support.
- Validation: Ensure data integrity with bounds and overlap checks.
- Extensibility: Flexible tier merging with custom strategies and robust querying capabilities.
- Performance: Efficient data structures with optional history tracking for operations.
Installation
Add textgrid to your Cargo.toml:
[]
= "0.1.0"
Or use cargo add:
Usage
Creating and manipulating a TextGrid
use ;
Loading and querying a TextGrid
use TextGrid;
Working with binary format
use ;
Custom tier merging
use ;
API Documentation
Full API documentation is available on (Docs.rs)[docs.rs]. Key components include:
TextGrid: Main structure with tiers and history.Tier: Represents an IntervalTier or PointTier.IntervalandPoint: Data types for annotations.TextGridError: Error handling for I/O and format issues.
Building and Testing
To build and test the crate locally:
The test suite include checks for undo/redo, tier merging, querying, and binary I/O.
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/your-feature). - Commit your changes (
git commit -am 'Add your feature'). - Push to the branch (
git push origin feature/your-feature). - Open a pull request.
Please ensure your code passes
cargo testand adheres to Rust formatting (cargo fmt).
License
This project is licensed under the CC-BY-NC-4.0 License.
Acknowledgments
- Built with Rust for performance and safety.
- Inspired by Praat's TextGrid format for phonetic research.