Immutable EARS requirements and extraction from text and MDC documents
let requirement = @ears.Requirement::Requirement(
"While enabled, when polled, the sensor shall report temperature.",
)
// requirement.pattern() == @ears.Complex
// requirement.preconditions() == ["enabled"]
// requirement.trigger() is Some(Event("polled"))
// requirement.system() == "sensor"
// requirement.response() == "report temperature."[Where <feature>,] [While <state>, ...]
[When <event>, | If <unwanted condition>, then]
the <system> shall <response>let spec = @ears.parse_text(
"The sensor shall measure.\nWhen polled, the sensor shall reply.\n",
)
let requirement = spec.requirements()[0].requirement()let spec = @ears.parse_markdown(
"---\ntitle: Sensor\n---\n- When **polled**, the sensor shall reply.\n",
)
// spec.document() retains the immutable MDC document and its frontmatter.
let document = @mdc.Document::Document("The sensor shall measure.")
let extracted = @ears.from_mdc(document)| Method | Adds | Example |
|---|---|---|
| modals | modal verbs besides shall; with a dialect, not after one negates it | must |
| determiners | words that start a subject besides the | each, an |
| pronouns | words that stand for a system | it |
| system_nouns | phrases that are a whole subject | Mission Control |
| lead_ins | phrases before the clauses | otherwise, for each |
| headings | Markdown headings that start a requirement block | level 3, Requirement: |
name: mission-control
modals: [must]
determiners: [each]
pronouns: [it]
systems: [Mission Control]
lead_ins: [otherwise, for each]
headings:
- level: 3
prefix: "Requirement:"mise exec -- moon test pkgs/ears tests/ears-acceptance tests/ears-laws --target jspub(all) suberror LexiconError {
InvalidWord(String)
InvalidPhrase(String)
InvalidHeadingPrefix(String)
InvalidHeadingLevel(Int)
InvalidLexiconFile(line~ : Int, message~ : String)
UnknownKey(key~ : String, line~ : Int)
WrongType(key~ : String, line~ : Int, expected~ : ValueKind)
InvalidEntry(key~ : String, line~ : Int, error~ : LexiconError)
} derive(Eq, Debug)pub(all) suberror ParseError {
EmptyRequirement
ExpectedSystem(at~ : SentencePosition)
MissingShall(at~ : SentencePosition)
MissingResponse(at~ : SentencePosition)
EmptyClause(keyword~ : Keyword, at~ : SentencePosition)
MissingSeparator(at~ : SentencePosition)
MissingThen(at~ : SentencePosition)
InvalidClauseOrder(at~ : SentencePosition)
UnresolvedPronoun(pronoun~ : Word, at~ : SentencePosition)
} derive(Eq, Debug)pub enum Origin {
Text(SourceRange)
Markdown(path~ : NodePath, span~ : SourceRange?)
} derive(Eq, Debug)type Phraseimpl Show for SentencePositiontype Wordfn parse_markdown(source : String, strict? : Bool, file? : String, dialects? : ArrayView[&Dialect]) -> Specification raise ParseErrorInstall
Download zipImmutable EARS requirements and extraction from text and MDC documents