Skip to content

Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.

Vocabulary: a short company name before a country domain is kept (corp.sap.de is Sap, not Corp) (#121)

Arda Zeybek03e2000626bb
diff --git a/app/src/main/vocab.ts b/app/src/main/vocab.ts
index 691faaf4..0df0b42d 100644
--- a/app/src/main/vocab.ts
+++ b/app/src/main/vocab.ts
@@ -12,6 +12,9 @@ export type MeetingWords = { title: string; names: string[]; companies: string[]
/** mail providers: their address says nothing about anyone's company */
const PROVIDERS = new Set(['gmail', 'googlemail', 'outlook', 'hotmail', 'live', 'msn', 'yahoo', 'ymail', 'icloud', 'me', 'mac', 'aol', 'proton', 'protonmail', 'pm', 'gmx', 'yandex', 'mail', 'fastmail', 'hey', 'zoho', 'qq', '163', '126', 'comcast', 'att', 'verizon'])
+/** the second-level labels under a country domain (co.uk, com.au) */
+const SECOND_LEVEL = new Set(['co', 'com', 'org', 'net', 'ac', 'gov', 'edu', 'ne', 'or', 'go', 'gob', 'nom'])
+
/** The company in a work address ([email protected]: Company); null for mail providers and names too short to be sure of */
export function companyOf(email: string): string | null {
const host = email.split('@')[1]?.toLowerCase().trim()
@@ -19,7 +22,7 @@ export function companyOf(email: string): string | null {
if (labels.length < 2) return null
const tld = labels.pop()!
// co.uk, com.au: the second-level part is not the name
- if (tld.length === 2 && labels.length > 1 && labels.at(-1)!.length <= 3) labels.pop()
+ if (tld.length === 2 && labels.length > 1 && SECOND_LEVEL.has(labels.at(-1)!)) labels.pop()
const name = labels.at(-1)!
const parts = name.split('-')
if (PROVIDERS.has(name) || parts.some((p) => !/^[a-z][a-z0-9]+$/.test(p)) || name.length < 3) return null
diff --git a/app/test/vocab.test.ts b/app/test/vocab.test.ts
index 8a1ee6c1..a266bbbc 100644
--- a/app/test/vocab.test.ts
+++ b/app/test/vocab.test.ts
@@ -17,6 +17,12 @@ describe('companyOf', () => {
expect(companyOf('[email protected]')).toBe('Acme')
expect(companyOf('[email protected]')).toBe('North-Wind')
})
+ it('keeps a short company name in front of a country domain, and skips only second-level labels', () => {
+ expect(companyOf('[email protected]')).toBe('Sap')
+ expect(companyOf('[email protected]')).toBe('Sap')
+ expect(companyOf('[email protected]')).toBe('Acme')
+ expect(companyOf('[email protected]')).toBe('Acme')
+ })
it('says nothing for mail providers or names too short to be sure of', () => {
for (const e of ['[email protected]', '[email protected]', '[email protected]', '[email protected]', 'no-at-sign', 'x@localhost']) expect(companyOf(e)).toBeNull()
})