Skip to content

Commit

Permalink
Amélioration de l'extraction des termes de recherche
Browse files Browse the repository at this point in the history
  • Loading branch information
lovasoa committed Sep 16, 2020
1 parent 99e840b commit 948e722
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ophirofox/content_scripts/europresse_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ function onLoad() {
const source = url.searchParams.get("ophirofox_source");
if (!source) return;
const source_url = new URL(source);
const lemonde_match = source_url.pathname.match(/([^/.]+)(\.html)?$/);
const lemonde_match = source_url.pathname.match(/([^/.]+)(_\d*_\d*\.html)?$/);
if (!lemonde_match) throw new Error("Could not find keywords in lemonde url");
const search_terms = lemonde_match[1].split(/[^a-z]+/).join(" ");
const stopwords = new Set(['d', 'l', 'et'])
const search_terms = lemonde_match[1].split('-').filter(w => !stopwords.has(w)).join(" ");
const keyword_field = document.getElementById("Keywords");
keyword_field.value = search_terms;
keyword_field.form.submit();
Expand Down

0 comments on commit 948e722

Please sign in to comment.