Skip to content

Commit

Permalink
use less regex
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanVukovic99 committed Mar 2, 2024
1 parent 884b0d3 commit 6e8c1cd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ext/js/language/de/german-transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import { prefixInflection, suffixInflection } from '../language-transforms.js';
import {prefixInflection, suffixInflection} from '../language-transforms.js';

// https://www.dartmouth.edu/~deutsch/Grammatik/Wortbildung/Separables.html
const separablePrefixes = ['ab', 'an', 'auf', 'aus', 'auseinander', 'bei', 'da', 'dabei', 'dar', 'daran', 'dazwischen', 'durch', 'ein', 'empor', 'entgegen', 'entlang', 'entzwei', 'fehl', 'fern', 'fest', 'fort', 'frei', 'gegenüber', 'gleich', 'heim', 'her', 'herab', 'heran', 'herauf', 'heraus', 'herbei', 'herein', 'herüber', 'herum', 'herunter', 'hervor', 'hin', 'hinab', 'hinauf', 'hinaus', 'hinein', 'hinterher', 'hinunter', 'hinweg', 'hinzu', 'hoch', 'los', 'mit', 'nach', 'nebenher', 'nieder', 'statt', 'um', 'vor', 'voran', 'voraus', 'vorbei', 'vorüber', 'vorweg', 'weg', 'weiter', 'wieder', 'zu', 'zurecht', 'zurück', 'zusammen'];
Expand Down
2 changes: 1 addition & 1 deletion ext/js/language/en/english-transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import { prefixInflection, suffixInflection } from '../language-transforms.js';
import {prefixInflection, suffixInflection} from '../language-transforms.js';

/**
* @param {string} consonants
Expand Down
4 changes: 2 additions & 2 deletions ext/js/language/language-transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function suffixInflection(inflectedSuffix, deinflectedSuffix, conditionsI
type: 'suffix',
isInflected: suffixRegExp,
deinflected: deinflectedSuffix,
deinflect: (text) => text.replace(suffixRegExp, deinflectedSuffix),
deinflect: (text) => text.slice(0, -inflectedSuffix.length) + deinflectedSuffix,
conditionsIn,
conditionsOut
};
Expand All @@ -47,7 +47,7 @@ export function prefixInflection(inflectedPrefix, deinflectedPrefix, conditionsI
return {
type: 'prefix',
isInflected: prefixRegExp,
deinflect: (text) => text.replace(prefixRegExp, deinflectedPrefix),
deinflect: (text) => deinflectedPrefix + text.slice(inflectedPrefix.length),
conditionsIn,
conditionsOut
};
Expand Down

0 comments on commit 6e8c1cd

Please sign in to comment.