Skip to content

Commit

Permalink
fix(verb): disable impossible participles (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph authored Jun 18, 2024
1 parent 2b822b9 commit 49b8759
Show file tree
Hide file tree
Showing 12 changed files with 6,465 additions and 6,418 deletions.
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { findLemmaById, toHTML } = require('./dist/__utils__');
const { findLemmaById, findPosTags, toHTML } = require('./dist/__utils__');

const isId = (value) => Number.isFinite(parseInt(value, 10));

Expand Down Expand Up @@ -92,6 +92,7 @@ const allureConfig = {
tags.push('deletion');
}

tags.push(...findPosTags(testCase.title));
return tags;
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/__utils__/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './toHTML';
export * from './findLemmaById';
export * from './lemmata';
export * as fixtures from './fixtures';
13 changes: 13 additions & 0 deletions src/__utils__/findLemmaById.ts → src/__utils__/lemmata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import { parsePos } from '../partOfSpeech';

const fixturesDir = path.join(__dirname, '../../src/__fixtures__');

Expand All @@ -9,6 +10,18 @@ export function findLemmaById(id: string): string {
return initFixtures().get(id)?.[2] ?? id;
}

export function findPosTags(id: string): string[] {
const pos = initFixtures().get(id)?.[1];
if (!pos) return [];

const { name, ...attributes } = parsePos(pos);
const trueAttributes = Object.entries(attributes)
.filter(([_, value]) => value)
.map(([key]) => key);

return [name, ...trueAttributes];
}

function initFixtures() {
if (!fixtures) {
const map = (fixtures = new Map());
Expand Down
3 changes: 3 additions & 0 deletions src/utils/compactArray.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function compactArray<T>(arr: (T | null | undefined)[]): T[] {
return arr.filter(Boolean) as T[];
}
1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './areArraysEqual';
export * from './compactArray';
export * from './memoizeLastCall';
export * from './removeBrackets';
export * from '../common/stripDiacritics';
Loading

0 comments on commit 49b8759

Please sign in to comment.