Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/lib/domain/network-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,23 @@ const STOPWORDS = new Set([
"months",
"year",
"semester",
"in",
"near",
"at",
"on",
"of",
"to",
]);

// "in the last six months" and "in 2024" describe dates, not places.
const NON_PLACE_START = /^(?:last|past|previous|next|recent|recently|this|today|yesterday|\d)/;

function placeAfterPreposition(value: string) {
const place = value.replace(/^the\b\s*/, "");
if (!place || place.length > 40 || NON_PLACE_START.test(place)) return null;
return place;
}

const COMMON_GEOS = [
"ukraine",
"europe",
Expand Down Expand Up @@ -360,7 +375,8 @@ export function parseNetworkObjective(input: z.infer<typeof networkSearchRequest
...manual.geographies,
// Whole words only, so "us" is not found inside "business" or "users".
...COMMON_GEOS.filter((geo) => new RegExp(`\\b${geo}\\b`).test(text)),
...placesAfterPrepositions(text),
// Dates such as "in the last six months" or "in 2024" are dropped.
...placesAfterPrepositions(text).map(placeAfterPreposition),
]);
const institutions = unique([
text.includes("berkeley") ? "Berkeley" : null,
Expand Down
24 changes: 24 additions & 0 deletions tests/network-search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,30 @@ describe("general network search", () => {
expect(kyiv.topics).toContain("robotics");
});

it("does not turn prepositions and date phrases into topics or geographies", () => {
const parsed = parseNetworkObjective({ query: "Find founders I met in the last six months", strictness: "balanced" }, now);
expect(parsed.geographies).toEqual([]);
expect(parsed.topics).not.toContain("in");
expect(parsed.positiveKeywords).not.toContain("in");
expect(parsed.dateRange?.preset).toBe("6 months");

const year = parseNetworkObjective({ query: "people I emailed in 2024 about climate", strictness: "balanced" }, now);
expect(year.geographies).toEqual([]);

const place = parseNetworkObjective({ query: "AI founders in the Bay Area", strictness: "balanced" }, now);
expect(place.geographies).toContain("bay area");

const results = search("Find founders I met in the last six months", [
candidate({
id: "person:other-teams",
entityType: "PERSON",
title: "Founder",
text: "founder building tools for other teams",
}),
]);
expect(results[0].evidence.some((item) => item.criterion === "Geography")).toBe(false);
});

it("supports recency and no-follow-up conditions", () => {
const results = search("Find founders I met but never followed up with", [
candidate({
Expand Down
Loading