Structured Language Form Crate
The structured_language_form crate provides a comprehensive and structured way to work with various poetic and literary forms, enabling applications in natural language processing, creative writing, and education. Whether you're generating poetry, analyzing text, or exploring structured language, this crate offers a robust foundation for handling a variety of structured language forms.
Features
- Comprehensive Enum: Represents a wide array of poetic and literary forms, including sonnets, odes, haikus, and many more.
- AI-Optimized Descriptions: Each variant is annotated with an
#[ai]attribute, providing concise descriptions of the form. - Random Generation: The crate includes utilities for random generation of structured language forms, with full support for seeded RNG to ensure reproducibility.
- Serialization: Supports serialization and deserialization for integration with external systems.
Usage
Add to Cargo.toml
[]
= "0.1.0"
= "0.8" # Required for random generation
= { = "1.0", = ["derive"] } # Optional for serialization
Example Code
use StructuredLanguageForm;
use SeedableRng;
use StdRng;
Enum Variants
Below is a sample of the structured language forms included in the crate:
- AlcaicStanza -- "4 lines, classical meter"
- Ballad -- "Quatrains, ABAB or ABCB"
- BlankVerse -- "Unrhymed iambic pentameter"
- Haiku -- "3 lines, 5-7-5 syllables"
- Sonnet -- "14-line poems with a specific rhyme scheme, often about love"
- Villanelle -- "19 lines, ABA ABA ABA ABA ABA ABAA"
- ... and many more.
Refer to the source code for the full list.
Random Generation
The crate supports deterministic random generation using the rand crate. This feature is ideal for testing and applications where reproducibility is crucial.
Example:
let mut rng = seed_from_u64;
let random_form = random_with_rng;
Serialization and Deserialization
With the serde feature enabled, you can serialize and deserialize StructuredLanguageForm instances into formats like JSON:
use serde_json;
use StructuredLanguageForm;
let form = Sonnet;
let serialized = to_string.unwrap;
let deserialized: StructuredLanguageForm = from_str.unwrap;
Integration
This crate integrates well with AI tools, natural language processing frameworks, and creative writing applications. The annotations (#[ai]) make it especially suitable for AI-driven systems that require metadata or descriptions of the variants.
Contributing
Contributions to the crate are welcome! Please open an issue or submit a pull request on the GitHub repository.
License
This crate is licensed under the MIT License. See the LICENSE file for details.