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
19 changes: 17 additions & 2 deletions packages/react-tei/src/termEnrichment/computeEnrichedTerms.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ describe("computeEnrichedTerms", () => {
]);
});

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

expect(terms).toEqual([
{ term: "cat lover", groups: ["group1"] },
{
term: "cat lover",
groups: ["group1"],
subTerms: [
{
groups: ["group1"],
term: "cat",
},
{
artificial: true,
groups: ["group1"],
sourceTerm: "cat lover",
term: " lover",
},
],
},
{ term: "cat", groups: ["group1"] },
]);
});
Expand Down
12 changes: 0 additions & 12 deletions packages/react-tei/src/termEnrichment/nestContainedTerms.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,6 @@ describe("nestContainedTerms", () => {
expect(isContainedIn(longerTerm, shorterTerm)).toBe(true);
});

it("should return false when longerTerm contain shorter one but they are of the same group", () => {
const longerTerm = {
term: "cat lover",
groups: ["group1"],
};
const shorterTerm = {
term: "cat",
groups: ["group1"],
};
expect(isContainedIn(longerTerm, shorterTerm)).toBe(false);
});

it('should return false when longerTerm contain shorter one but shorter is not a full word (e.g., "conf" in "overconfident")', () => {
const longerTerm = {
term: "overconfident",
Expand Down
3 changes: 0 additions & 3 deletions packages/react-tei/src/termEnrichment/nestContainedTerms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ export const isContainedIn = (
longer: GroupedTerm,
shorter: GroupedTerm,
): boolean => {
if (shorter.groups.every((g) => longer.groups.includes(g))) {
return false;
}
if (shorter.term === longer.term) return false;

const shorterWordRegex = new RegExp(
Expand Down