What we changed
We fixed how the main clause verb is chosen, how contractions are built and expanded (can't, he's not, wanna), verb and noun conversions, dates (fortnight, a month's time) and the match pattern parser. We also fixed the payload and speech plugins and a test that crashed the test run against the built library.
What this work shows
- Natural language processing (NLP)
- Syntax parsing: subject, verb, subordinate clauses
- Tokenisation and match pattern parsing
- Regression tests with tape
What was broken The verb came from a secondary clause
mainClause dropped every part of a sentence containing that or who, so in a sentence with a list after "that included" the verb came out as "state engineering" instead of "led". Sentences opening with "To win", "Had I known" or "In case", and a relative clause right after the subject ("The boy who you saw..."), also took the verb from the wrong part.
How we fixed it The verb comes from the main clause
A part of a sentence is now dropped only when the subordinator or relative pronoun comes before its own verb, and "since 2010" or "once upon a time" no longer count as subordinators. We recognise more openers of a secondary clause and skip the verb of a relative clause after the subject: on a probe of 20 sentences with such openers, 18 now come out right instead of 14.
#1225 #1224 #1222
What was broken Contractions came out mangled
contract() turned "can not" into "cann't" and "he is not" into "he'sn't", and treated two matches in one sentence as one: "he is here and she is there" became "he'shere and there". Expanding "I wanna pickle" added a stray "to", and "Leonard's was Randall" became "Leonard has was".
How we fixed it Each contraction is built on its own
Each match is contracted on its own, "can not" gives "can't", "he is not" gives "he's not", and the n't list now covers "did not" and "were not". "wanna" before a noun expands to "want" without "to", and 's before is, are, was, were or am is read as possessive.
#1244 #1243 #1240 #1237 #1230
What was broken Conversions lost meaning and letter case
toPositive() only turned "He does not like camels" into "He does like camels", and going to the infinitive turned "I will never do that" into "I do not never do that". toSingular made "Great Danes" into "great dane", and a capitalised "Higher" before "than" was tagged as a proper noun.
How we fixed it Correct forms and original letter case
toPositive() drops does and did and inflects the verb ("He likes camels", "she went home"), and toNegative() still restores the original. never stays without an extra "do not", toSingular gives each word back its original case, all caps included, and a known comparative right before "than" stays an adjective.
#1242 #1239 #1229 #1228
What was broken The dates plugin missed some phrases
fortnight was not in the duration lexicon, so "in a fortnight" did not work, and "in a month's time" matched no unit because parseUnit only stripped a trailing s. In "2025-05-11 - They have taken the bridge", .dates().text() returned the dash as well.
How we fixed it Two weeks, a month and a clean date
fortnight is in the duration lexicon and counts as two weeks, and parseUnit also strips 's, so "in a month's time" lands a month out. A spaced dash after the last word of a match is dropped like other end punctuation, while the range "june 5 - june 7" stays whole.
#1247 #1236 #1231
What was broken Matching ignored some characters
The tokeniser cut the closing bracket off "foo(bar)", and lexicon words starting with # or @, such as #GoJetsGo, never matched. The match parser split hyphens differently from the tokeniser, so has("x-ray") looked for "x ray", and + or / escaped with a backslash still acted as an operator and a regex.
How we fixed it The parser reads characters like the tokeniser
A closing bracket that closes one inside the word stays in the word, for [] and {} too. The lexicon lookup also tries the normal form with # or @, the match parser splits hyphens with the tokeniser's own hasHyphen, and escaped + and / are read as plain characters.
#1253 #1249 #1248 #1241
What was broken The payload and speech plugins went wrong
The payload plugin looked data up by sentence number, so after .remove() of an earlier sentence later payloads landed on the wrong words or went missing, and a new document could see an old one's payloads. The speech plugin merged the -ent syllable into the first one in silent, talent, parent and agent, and pnpm testb crashed with doc.normalize is not a function.
How we fixed it Payloads survive .remove(), syllables split
Payloads are found by the ids of their first and last terms, so they survive .remove(), and the limitations section is gone from the README. silent, talent, parent and agent now have two syllables, and the regex-boundaries test uses the full build, which includes normalize.
#1246 #1233 #1232
What was broken An empty string replaced the whole document
replace('dog', '') on the document "the dog sat on the mat" turned the whole text into "dog". The empty string was read as a missing second argument, so the call went to replaceWith('dog').
How we fixed it An empty string removes the match
replace now hands over to replaceWith only when the second argument is undefined. replace('dog', '') gives "the sat on the mat", just like match('dog').replaceWith(''), and a new test also checks a document with two sentences.
#1278