Skip to content

Commit 168317b

Browse files
committed
fix(library): start sim-count clauses only at a new capitalized subject and tell count lists from new clauses
1 parent 9527a59 commit 168317b

2 files changed

Lines changed: 33 additions & 11 deletions

File tree

‎scripts/check-library-content.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,13 @@ describe('check-library-content', () => {
356356
],
357357
['Sim, unlike Make.com, has 1,000+ integrations.', '1,000+ integrations', 'overstates'],
358358
['Sim connects tools like Slack to 1,000+ integrations.', '1,000+ integrations', 'overstates'],
359+
['Sim is open source but has 1,000+ integrations.', '1,000+ integrations', 'overstates'],
360+
['Sim is open source, but has 1,000+ integrations.', '1,000+ integrations', 'overstates'],
361+
[
362+
'While Sim is open source but has 1,000+ integrations, Zapier is proprietary.',
363+
'1,000+ integrations',
364+
'overstates',
365+
],
359366
[
360367
'While Sim has 280+ integrations, 9,000+ actions, and 530+ triggers, Zapier focuses on simple automations.',
361368
'9,000+ actions',
@@ -427,6 +434,8 @@ describe('check-library-content', () => {
427434
'Sim is open source but Zapier has 9,000+ integrations.',
428435
'While Sim has 280+ integrations but Zapier has 9,000+ integrations, both support webhooks.',
429436
'"Sim is open source." Zapier has 9,000+ integrations.',
437+
'While Sim has 280+ integrations, 9,000+ integrations are available in Zapier.',
438+
'Sim has 280+ integrations, and Zapier has 9,000+ integrations.',
430439
'While Sim has 280+ integrations, Zapier lists 9,000+ integrations.',
431440
'Zapier, like Sim, has 9,000+ integrations.',
432441
'Sim, unlike Zapier, which has 9,000+ integrations, is open source.',

‎scripts/check-library-content.ts‎

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
* "1,000+ integrations" or a figure left from an older catalog spreads to third-party sites.
3636
* A count belongs to Sim when "Sim" comes before it in the same clause and no other product's
3737
* possessive directly precedes it, or when it sits in a table row whose label cell is Sim.
38-
* A comparison ("while", "unlike", "compared with", or "like" after a comma) is its own clause
39-
* up to the next comma, and the sentence's main clause resumes after it.
38+
* A comparison that opens a sentence or names a new subject ("while Zapier", "Zapier, like
39+
* Sim,") is its own clause up to the next comma, and the main clause resumes after it; ", and"
40+
* before a capitalized word also starts a new clause.
4041
* A count whose owner is ambiguous within its clause is treated as Sim's; when it belongs to
4142
* another product, name that product as its owner ("Zapier's 9,000+") or give it a sentence.
4243
* Blog and changelog posts are dated, so their counts are true as of publication.
@@ -149,24 +150,32 @@ const LINE_PREFIX = /^\s*(?:(?:[-*+>]|\d+[.)]|#{1,6})\s+)*(?:\w+:\s*["'])?/
149150
const SIM_NAME = /\bSim\b/
150151
/** Words that turn a sentence toward another product: "while Zapier lists ...", "unlike Zapier". */
151152
const CONTRAST = String.raw`(?:while|whereas|but|unlike|compared (?:with|to)|versus|vs\.?)`
153+
/** The same words opening a sentence, plus "Like" ("Like Sim, n8n ..."). */
154+
const OPENING_CONTRAST = String.raw`(?:While|Whereas|But|Unlike|Like|Compared (?:with|to)|Versus|Vs\.?)`
152155
/** Sentence punctuation, with any closing quote or bracket, before whitespace. */
153156
const SENTENCE_END = /(?<=[.!?;]['"”’)\]]*)\s+/
157+
/** ", and" before a capitalized word, which starts a clause with its own subject. */
158+
const NEW_SUBJECT = /,\s+and\s+(?=[A-Z])/
154159
/**
155-
* Where a comparison clause starts: a contrast word, or "like" when it opens the sentence or
156-
* follows a comma ("Like Sim, ...", "Zapier, like Sim, ..."), but not "tools like Slack".
160+
* Where a comparison clause starts: a sentence-opening contrast ("Unlike Sim, ..."), or a contrast
161+
* followed by a capitalized word, the new subject ("..., while Zapier", "Zapier, like Sim, ...").
162+
* A contrast that keeps the subject ("open source but has ...") does not start one.
157163
*/
158164
const COMPARISON_START = new RegExp(
159-
String.raw`(?:^|,\s*|\s+)(?=${CONTRAST}\b)|(?:^|,\s*)(?=like\b)`,
160-
'i'
165+
String.raw`^(?=${OPENING_CONTRAST}\b)|,\s*(?=(?:like|${CONTRAST})\s+[A-Z])|\s+(?=${CONTRAST}\s+[A-Z])`
161166
)
167+
/** A count continuing a list ("..., 9,000+ actions, and 530+ triggers, ..."), not a new clause. */
168+
const COUNT_LIST_ITEM = String.raw`(?:and\s+)?\d[\d,]*\+?\s+(?:integrations|actions|triggers)\b\s*(?:,|and\b|$)`
162169
/**
163170
* Where a comparison clause ends: the first comma that is not a thousands separator, not the
164171
* start of a relative clause continuing it ("unlike Zapier, which has 9,000+ integrations"), and
165-
* not the next item in a list of counts ("280+ integrations, 9,000+ actions, and 530+ triggers").
172+
* not the next item in a list of counts.
166173
*/
167-
const COMPARISON_END = /,(?!\d)(?!\s*(?:which|that|who)\b)(?!\s*(?:and\s+)?\d)/
168-
/** A contrast inside a comparison clause, which starts a clause of its own ("..., but Zapier"). */
169-
const INNER_CONTRAST = new RegExp(String.raw`,?\s+(?=${CONTRAST}\b)`, 'i')
174+
const COMPARISON_END = new RegExp(
175+
String.raw`,(?!\d)(?!\s*(?:which|that|who)\b)(?!\s*${COUNT_LIST_ITEM})`
176+
)
177+
/** A contrast with a new subject inside a comparison clause ("..., but Zapier has ..."). */
178+
const INNER_CONTRAST = new RegExp(String.raw`,?\s+(?=${CONTRAST}\s+[A-Z])`)
170179
/** The product whose possessive directly precedes a count, as in "Zapier's 9,000+". */
171180
const POSSESSIVE_OWNER = /([\w.-]+)['’]s\s*$/
172181
/** A Sim count below this share of the catalog total is left from an older catalog. */
@@ -200,7 +209,11 @@ function sentenceClauses(sentence: string): string[] {
200209

201210
/** Each count whose clause names Sim before it, unless another product's possessive owns it. */
202211
function simProseCounts(text: string): RegExpMatchArray[] {
203-
const clauses = text.replace(LINE_PREFIX, '').split(SENTENCE_END).flatMap(sentenceClauses)
212+
const clauses = text
213+
.replace(LINE_PREFIX, '')
214+
.split(SENTENCE_END)
215+
.flatMap((sentence) => sentence.split(NEW_SUBJECT))
216+
.flatMap(sentenceClauses)
204217
return clauses.flatMap((clause) =>
205218
[...clause.matchAll(COUNT_CLAIM)].filter((match) => {
206219
const before = clause.slice(0, match.index)

0 commit comments

Comments
 (0)