Skip to content

Commit 8ba80b9

Browse files
committed
nest term of the same group
1 parent dc831cb commit 8ba80b9

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

packages/react-tei/src/termEnrichment/computeEnrichedTerms.spec.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ describe("computeEnrichedTerms", () => {
260260
]);
261261
});
262262

263-
it("should not nest terms that are in the same group", () => {
263+
it("should nest terms that are in the same group", () => {
264264
const termByGroup = {
265265
group1: [
266266
{ term: "cat lover", displayed: true },
@@ -271,7 +271,22 @@ describe("computeEnrichedTerms", () => {
271271
const terms = computeEnrichedTerms(termByGroup);
272272

273273
expect(terms).toEqual([
274-
{ term: "cat lover", groups: ["group1"] },
274+
{
275+
term: "cat lover",
276+
groups: ["group1"],
277+
subTerms: [
278+
{
279+
groups: ["group1"],
280+
term: "cat",
281+
},
282+
{
283+
artificial: true,
284+
groups: ["group1"],
285+
sourceTerm: "cat lover",
286+
term: " lover",
287+
},
288+
],
289+
},
275290
{ term: "cat", groups: ["group1"] },
276291
]);
277292
});

packages/react-tei/src/termEnrichment/nestContainedTerms.spec.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,6 @@ describe("nestContainedTerms", () => {
3939
expect(isContainedIn(longerTerm, shorterTerm)).toBe(true);
4040
});
4141

42-
it("should return false when longerTerm contain shorter one but they are of the same group", () => {
43-
const longerTerm = {
44-
term: "cat lover",
45-
groups: ["group1"],
46-
};
47-
const shorterTerm = {
48-
term: "cat",
49-
groups: ["group1"],
50-
};
51-
expect(isContainedIn(longerTerm, shorterTerm)).toBe(false);
52-
});
53-
5442
it('should return false when longerTerm contain shorter one but shorter is not a full word (e.g., "conf" in "overconfident")', () => {
5543
const longerTerm = {
5644
term: "overconfident",

packages/react-tei/src/termEnrichment/nestContainedTerms.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ export const isContainedIn = (
77
longer: GroupedTerm,
88
shorter: GroupedTerm,
99
): boolean => {
10-
if (shorter.groups.every((g) => longer.groups.includes(g))) {
11-
return false;
12-
}
1310
if (shorter.term === longer.term) return false;
1411

1512
const shorterWordRegex = new RegExp(

0 commit comments

Comments
 (0)