Phrase keys and target keys in core, so the page can record a decline itself
The normalised phrase a decline records (nolink:<phrase>) and a target's identity move from server/links to src/core/links.ts, which the browser can import; the server modules re-export them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
1 parent
f9ce8faf6b
commit
428f7290ee
3 files changed
+38
-23
No files matched your search
+3
-15
@@ -9,8 +9,11 @@
|
||||
* lookups per node bounded.
|
||||
*/
|
||||
import type { Mark } from "../../src/core/marks";
|
||||
import { phraseKey } from "../../src/core/links";
|
||||
import { UNLISTED, listed, rank, singular } from "./words";
|
||||
|
||||
export { phraseKey };
|
||||
|
||||
export type Kind = "forced" | "name" | "term" | "noun";
|
||||
|
||||
export interface Candidate {
|
||||
@@ -97,21 +100,6 @@ const low = (w: string) => w.toLowerCase();
|
||||
/** An adverb in -ly ("roughly", "independently"), when the stem is a word. */
|
||||
const adverb = (w: string) => /ly$/i.test(w) && w.length > 5 && listed(low(w)) && rank(low(w)) < UNLISTED && (listed(low(w).slice(0, -2)) || listed(low(w).slice(0, -3) + "e") || /ally$/i.test(w));
|
||||
|
||||
/** Normalised form of a phrase, for comparing phrases with each other and with titles. */
|
||||
export function phraseKey(s: string): string {
|
||||
return s
|
||||
.normalize("NFKD")
|
||||
.replace(/\p{M}/gu, "")
|
||||
.toLowerCase()
|
||||
.replace(/['’]s\b/g, "")
|
||||
.replace(/[-–‑_/]/g, " ")
|
||||
.replace(/[^\p{L}\p{N}\s]/gu, "")
|
||||
.split(/\s+/)
|
||||
.filter(Boolean)
|
||||
.filter((w, i, all) => !(i === 0 && all.length > 1 && (w === "the" || w === "a" || w === "an")))
|
||||
.map(singular)
|
||||
.join(" ");
|
||||
}
|
||||
|
||||
function variants(text: string): string[] {
|
||||
const out = [text];
|
||||
|
||||
Reference in new issue
Block a user