Skip to content

Commit

Permalink
modify LanguageNormalizer.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
roumcha committed Oct 15, 2023
1 parent a9e6a2e commit 767ff59
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions atcoder-problems-frontend/src/utils/LanguageNormalizer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
const mapping: [beginning: string, normalized: string][] = [
["PyPy", "Python"],
["Python (Cython", "Cython"],
["Assembly x64", "Assembly x64"],
["Awk", "AWK"],
["IOI-Style", "C++"],
["LuaJIT", "Lua"],
["Seed7", "Seed7"],
["Perl6", "Raku"],
["Objective-C", "Objective-C"],
];

export const normalizeLanguage = (language: string): string => {
if (language.startsWith("Perl6")) {
return "Raku";
} else {
return language.replace(/\d*\s*\(.*\)$/, "");
for (const [beginning, normalized] of mapping) {
if (language.startsWith(beginning)) {
return normalized;
}
}

return language.replace(/\s*[\d(\-].*/, "") || "Unknown";
};

0 comments on commit 767ff59

Please sign in to comment.