Skip to content

Commit e95e3bf

Browse files
committed
fix(library): remove sim-count comparison asides for any subject and keep counted openers
1 parent ac63c10 commit e95e3bf

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ describe('check-library-content', () => {
339339
'overstates',
340340
],
341341
['Sim, unlike n8n, has 1,000+ integrations.', '1,000+ integrations', 'overstates'],
342+
[
343+
'While Sim has 1,000+ integrations, Zapier focuses on simple automations.',
344+
'1,000+ integrations',
345+
'overstates',
346+
],
342347
['Sim | Governed agents | 1,000+ integrations |', '1,000+ integrations', 'overstates'],
343348
[
344349
'[Sim](https://www.sim.ai) combines [Chat](https://docs.sim.ai/execution/chat) with 1,000+ integrations.',
@@ -396,6 +401,9 @@ describe('check-library-content', () => {
396401
'- Unlike Sim, Zapier lists 9,000+ integrations.',
397402
"Sim has fewer than [Zapier](https://zapier.com)'s 9,000+ integrations.",
398403
'Sim has 280+ integrations, unlike Zapier, which has 9,000+ integrations.',
404+
'Zapier, unlike Sim, has 9,000+ integrations.',
405+
'Zapier, like Sim, has 9,000+ integrations.',
406+
'Sim, unlike Zapier, which has 9,000+ integrations, is open source.',
399407
'n8n | Alternative to Sim | 2,000+ integrations |',
400408
'Sim has 280+ integrations, while Zapier lists 9,000+ integrations.',
401409
"Sim has 280+ integrations, fewer than Zapier's 9,000+ integrations.",

‎scripts/check-library-content.ts‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,24 @@ const SIM_NAME = /\bSim\b/
149149
/** Words that turn a sentence toward another product: "while Zapier lists ...", "unlike Zapier". */
150150
const CONTRAST = String.raw`(?:while|whereas|but|unlike|compared (?:with|to)|versus|vs\.?)`
151151
/**
152-
* A comparison set off by commas right after Sim, as in "Sim, unlike Zapier, has ...". The span
153-
* ends at the first comma that is not a thousands separator, so "Sim, unlike n8n, ..." matches.
152+
* A comparison set off by commas, as in "Sim, unlike Zapier, has ..." or "Zapier, like Sim, has
153+
* ...", removed so the sentence keeps its subject. The span ends at the first comma that is not a
154+
* thousands separator, and it is kept when a relative clause follows ("unlike Zapier, which has").
154155
*/
155-
const SIM_PARENTHETICAL = new RegExp(
156-
String.raw`\bSim,\s+(?:like|${CONTRAST})\s+(?:[^,]|,(?=\d))*?,(?!\d)`,
156+
const PARENTHETICAL_COMPARISON = new RegExp(
157+
String.raw`,\s+(?:like|${CONTRAST})\s+(?:[^,]|,(?=\d))*?,(?!\d)(?!\s*(?:which|that|who)\b)`,
157158
'gi'
158159
)
159160
/** A sentence end, or a contrast that hands the rest of the sentence to another subject. */
160161
const CLAUSE_BREAK = new RegExp(String.raw`(?<=[.!?;])\s+|,?\s+${CONTRAST}\s+`, 'i')
161-
/** An opening comparison ("Unlike Sim, ...") whose main clause is about another product. */
162-
const LEADING_COMPARISON = new RegExp(String.raw`^(?:like|${CONTRAST})\b[^,]*,\s*`, 'i')
162+
/**
163+
* An opening comparison ("Unlike Sim, ...") whose main clause is about another product. An opener
164+
* that states a count of its own ("While Sim has 280+ integrations, ...") is kept.
165+
*/
166+
const LEADING_COMPARISON = new RegExp(
167+
String.raw`^(?:like|${CONTRAST})\b(?:[^,]|,(?=\d))*?,(?!\d)\s*`,
168+
'i'
169+
)
163170
/** The product whose possessive directly precedes a count, as in "Zapier's 9,000+". */
164171
const POSSESSIVE_OWNER = /([\w.-]+)['’]s\s*$/
165172
/** A Sim count below this share of the catalog total is left from an older catalog. */
@@ -177,10 +184,14 @@ function simTableRowCounts(cells: string[]): RegExpMatchArray[] {
177184
function simProseCounts(text: string): RegExpMatchArray[] {
178185
const sentences = text
179186
.replace(LINE_PREFIX, '')
180-
.replace(SIM_PARENTHETICAL, 'Sim')
187+
.replace(PARENTHETICAL_COMPARISON, '')
181188
.split(CLAUSE_BREAK)
182189
return sentences.flatMap((sentence) => {
183-
const clause = sentence.replace(LEADING_COMPARISON, '')
190+
const opener = LEADING_COMPARISON.exec(sentence)?.[0]
191+
const clause =
192+
opener !== undefined && opener.match(COUNT_CLAIM) === null
193+
? sentence.slice(opener.length)
194+
: sentence
184195
return [...clause.matchAll(COUNT_CLAIM)].filter((match) => {
185196
const before = clause.slice(0, match.index)
186197
const owner = POSSESSIVE_OWNER.exec(before)?.[1]

0 commit comments

Comments
 (0)