THINK FIRST·CODE LATER

← All labs

Requirement linter with EARS detection

Problem

Write a linter for requirement sentences. Read lines until the end of input; each line is ID: text. For each requirement print its EARS pattern and its problems.

Pattern (case-insensitive, on the text after ID: ):

  • starts with when → EVENT
  • starts with while → STATE
  • starts with where → OPTIONAL
  • starts with if and contains then → UNWANTED
  • starts with if without then → UNWANTED? (incomplete)
  • otherwise → UBIQUITOUS

Problems (in this order):

  1. no shall in the text → no 'shall'
  2. each weak word from this list that appears (substring, list order): appropriate, user-friendly, fast, easy, efficient, as much as possible, etc, and/or, flexible → weak word: <w>
  3. the text contains the word it or they as a whole word (ignore punctuation) → pronoun: check who it refers to

Output: ID [PATTERN] OK or ID [PATTERN] problems: p1; p2; .... At the end: Checked n requirements, k with problems.

Input:

R1: When a post receives 3 reports from different students, the system shall hide the post.
R2: The app shall be fast and user-friendly.
R3: If login fails 5 times, the system shall lock it.

Output:

R1 [EVENT] OK
R2 [UBIQUITOUS] problems: weak word: user-friendly; weak word: fast
R3 [UNWANTED?] problems: pronoun: check who it refers to
Checked 3 requirements, 2 with problems

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.