frontend: improve title compare for MangaUpdates relation finding
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
"@popperjs/core": "^2.11.8",
|
"@popperjs/core": "^2.11.8",
|
||||||
"bootstrap": "^5.3.2",
|
"bootstrap": "^5.3.2",
|
||||||
"bootstrap-vue-next": "^0.14.10",
|
"bootstrap-vue-next": "^0.14.10",
|
||||||
|
"html-entities": "^2.4.0",
|
||||||
"idb": "^7.1.1",
|
"idb": "^7.1.1",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
"pinia-class-component": "^0.9.4",
|
"pinia-class-component": "^0.9.4",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import type {MangaUpdatesSearchResultRecord} from '@/data/models/mangaupdates/Ma
|
|||||||
import stringSimilarity from 'string-similarity-js';
|
import stringSimilarity from 'string-similarity-js';
|
||||||
import {ApiError} from '@/data/api/ApiUtils';
|
import {ApiError} from '@/data/api/ApiUtils';
|
||||||
import groupBy from '@/util';
|
import groupBy from '@/util';
|
||||||
|
import {decode} from 'html-entities';
|
||||||
|
|
||||||
export default class MangaUpdatesDataService {
|
export default class MangaUpdatesDataService {
|
||||||
private readonly mangaUpdatesApi = new MangaUpdatesApi();
|
private readonly mangaUpdatesApi = new MangaUpdatesApi();
|
||||||
@@ -59,8 +60,11 @@ export default class MangaUpdatesDataService {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const cleaner = (str: string) => {
|
||||||
|
return str.toLowerCase().replaceAll('"', '\'').replaceAll(' - ', ' ').replaceAll(': ', ' ');
|
||||||
|
};
|
||||||
matching = results.results
|
matching = results.results
|
||||||
.filter(e => stringSimilarity(title, e.record.title, 2, false) >= 0.95)
|
.filter(e => stringSimilarity(cleaner(title), cleaner(decode(e.record.title)), 2, false) >= 0.95)
|
||||||
.filter(e => allowTypes.has(e.record.type.toLowerCase())) //check if a manga or similar but not novel
|
.filter(e => allowTypes.has(e.record.type.toLowerCase())) //check if a manga or similar but not novel
|
||||||
.filter(e => m.startDate.year - 1 <= parseInt('' + e.record.year)
|
.filter(e => m.startDate.year - 1 <= parseInt('' + e.record.year)
|
||||||
&& parseInt('' + e.record.year) <= m.startDate.year + 1); //check year +-1
|
&& parseInt('' + e.record.year) <= m.startDate.year + 1); //check year +-1
|
||||||
|
|||||||
@@ -8,6 +8,11 @@
|
|||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./src/*"]
|
"@/*": ["./src/*"]
|
||||||
}
|
},
|
||||||
|
"lib": [
|
||||||
|
"ES2021",
|
||||||
|
"DOM",
|
||||||
|
"DOM.Iterable"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
"extends": "./tsconfig.app.json",
|
"extends": "./tsconfig.app.json",
|
||||||
"exclude": [],
|
"exclude": [],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"experimentalDecorators": true,
|
|
||||||
"composite": true,
|
|
||||||
"lib": [],
|
|
||||||
"types": ["node", "jsdom"]
|
"types": ["node", "jsdom"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user