From 7286ddbecfce4f6b3657b8da9d4088c2fbf6b924 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Thu, 7 Apr 2022 21:05:18 +0100 Subject: [PATCH 1/7] make journal autocomplete use the new endpoint --- static/js/jct.js | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/static/js/jct.js b/static/js/jct.js index 46cae4d..8f6bd31 100644 --- a/static/js/jct.js +++ b/static/js/jct.js @@ -784,6 +784,21 @@ jct.d.toggle_detailed_results = () => { } } +jct.suggest_prepare = (txt, stop_words) => { + txt = txt.toLowerCase().trim(); + for (let sw of stop_words) { + // FIXME: need to make the second and third only replace at the start and the end + txt = txt.replace(" " + sw + " ", " ").replace(sw + " ", "").replace(" " + sw, "") + } + while (true) { + if (!(txt.includes(" "))) { + break + } + txt.replace(" ", " ") + } + return txt +} + ////////////////////////////////////////////////////////// // Initialisation @@ -836,23 +851,26 @@ jct.setup = (manageUrl=true) => { autocomplete: "off" }, options : function(text, callback) { + let effectiveTextLength = text.length; let pattern = /[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9xX]/; - if (pattern.test(text)) { - text = text.toUpperCase(); - } else { - text = text.toLowerCase().replace(' of','').replace('the ',''); + if (!pattern.test(text)) { + // let effective_text = text.toLowerCase().replace(' of','').replace('the ',''); + let effective_text = jct.suggest_prepare(text, ["of", "the", "and", "journa", "journal"]) + effectiveTextLength = effective_text.length + // text = text.toLowerCase().replace(' of','').replace('the ',''); } - if (text.length > 1) { + if (effectiveTextLength > 3) { let ourcb = (xhr) => { let js = JSON.parse(xhr.response); callback(js.data); } - jct.jx('suggest/journal/'+text, false, ourcb); + // jct.jx('suggest/journal/'+text, false, ourcb); + jct.jx('suggest/jac/'+text, false, ourcb); } }, optionsTemplate : function(obj) { let t = obj.title; - let issns = obj.issn.join(", "); + let issns = obj.issns.join(", "); let publisher = obj.publisher; let frag = ""; @@ -871,7 +889,7 @@ jct.setup = (manageUrl=true) => { }, selectedTemplate : function(obj) { let t = obj.title; - let issns = obj.issn; + let issns = obj.issns; let publisher = obj.publisher; let frag = ""; From 1e15876686a703d7efe22f4b7824ff5a584a2c4a Mon Sep 17 00:00:00 2001 From: Anusha Ranganathan Date: Tue, 19 Apr 2022 02:38:23 +0100 Subject: [PATCH 2/7] changed ui to use new endpoint --- static/js/jct.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/jct.js b/static/js/jct.js index c53064e..236cc80 100644 --- a/static/js/jct.js +++ b/static/js/jct.js @@ -973,7 +973,7 @@ jct.setup = (manageUrl=true) => { let js = JSON.parse(xhr.response); callback(js.data); } - jct.jx('suggest/institution/'+text, false, ourcb); + jct.jx('suggest/iac/'+text, false, ourcb); } }, optionsTemplate : function(obj) { From d0ecb293b3d8fe7b35709a63841935d0a66611d2 Mon Sep 17 00:00:00 2001 From: Anusha Ranganathan Date: Fri, 22 Apr 2022 19:16:23 +0100 Subject: [PATCH 3/7] Changed suggest endpoints to old paths --- static/js/jct.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/js/jct.js b/static/js/jct.js index 7b0914e..c569402 100644 --- a/static/js/jct.js +++ b/static/js/jct.js @@ -865,7 +865,7 @@ jct.setup = (manageUrl=true) => { callback(js.data); } // jct.jx('suggest/journal/'+text, false, ourcb); - jct.jx('suggest/jac/'+text, false, ourcb); + jct.jx('suggest/journal/'+text, false, ourcb); } }, optionsTemplate : function(obj) { @@ -991,7 +991,7 @@ jct.setup = (manageUrl=true) => { let js = JSON.parse(xhr.response); callback(js.data); } - jct.jx('suggest/iac/'+text, false, ourcb); + jct.jx('suggest/institution/'+text, false, ourcb); } }, optionsTemplate : function(obj) { From 141852710fa9fd42659dd2a7ca9b6af8d2e29650 Mon Sep 17 00:00:00 2001 From: Anusha Ranganathan Date: Fri, 22 Apr 2022 19:38:38 +0100 Subject: [PATCH 4/7] modified institution to not strip any words --- static/js/jct.js | 2 +- static/js/jct_plugin.js | 34 ++++++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/static/js/jct.js b/static/js/jct.js index c569402..49aa1f6 100644 --- a/static/js/jct.js +++ b/static/js/jct.js @@ -985,7 +985,7 @@ jct.setup = (manageUrl=true) => { autocomplete: "off" }, options : function(text, callback) { - text = text.toLowerCase().replace(' of','').replace('the ',''); + text = text.toLowerCase(); //.replace(' of','').replace('the ',''); if (text.length > 1) { let ourcb = (xhr) => { let js = JSON.parse(xhr.response); diff --git a/static/js/jct_plugin.js b/static/js/jct_plugin.js index 627a151..cefb660 100644 --- a/static/js/jct_plugin.js +++ b/static/js/jct_plugin.js @@ -1122,6 +1122,21 @@ jct.d.toggle_detailed_results = () => { } } +jct.suggest_prepare = (txt, stop_words) => { + txt = txt.toLowerCase().trim(); + for (let sw of stop_words) { + // FIXME: need to make the second and third only replace at the start and the end + txt = txt.replace(" " + sw + " ", " ").replace(sw + " ", "").replace(" " + sw, "") + } + while (true) { + if (!(txt.includes(" "))) { + break + } + txt.replace(" ", " ") + } + return txt +} + ////////////////////////////////////////////////////////// // Initialisation @@ -1174,23 +1189,26 @@ jct.setup = (manageUrl=true) => { autocomplete: "off" }, options : function(text, callback) { + let effectiveTextLength = text.length; let pattern = /[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9xX]/; - if (pattern.test(text)) { - text = text.toUpperCase(); - } else { - text = text.toLowerCase().replace(' of','').replace('the ',''); + if (!pattern.test(text)) { + // let effective_text = text.toLowerCase().replace(' of','').replace('the ',''); + let effective_text = jct.suggest_prepare(text, ["of", "the", "and", "journa", "journal"]) + effectiveTextLength = effective_text.length + // text = text.toLowerCase().replace(' of','').replace('the ',''); } - if (text.length > 1) { + if (effectiveTextLength > 3) { let ourcb = (xhr) => { let js = JSON.parse(xhr.response); callback(js.data); } + // jct.jx('suggest/journal/'+text, false, ourcb); jct.jx('suggest/journal/'+text, false, ourcb); } }, optionsTemplate : function(obj) { let t = obj.title; - let issns = obj.issn.join(", "); + let issns = obj.issns.join(", "); let publisher = obj.publisher; let frag = ""; @@ -1209,7 +1227,7 @@ jct.setup = (manageUrl=true) => { }, selectedTemplate : function(obj) { let t = obj.title; - let issns = obj.issn; + let issns = obj.issns; let publisher = obj.publisher; let frag = ""; @@ -1305,7 +1323,7 @@ jct.setup = (manageUrl=true) => { autocomplete: "off" }, options : function(text, callback) { - text = text.toLowerCase().replace(' of','').replace('the ',''); + text = text.toLowerCase(); //.replace(' of','').replace('the ',''); if (text.length > 1) { let ourcb = (xhr) => { let js = JSON.parse(xhr.response); From af5502fbc3590ba86f405d3cbcb204f98c3fe144 Mon Sep 17 00:00:00 2001 From: Anusha Ranganathan Date: Fri, 22 Apr 2022 19:42:29 +0100 Subject: [PATCH 5/7] Bumped version of js --- config/_default/params.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/_default/params.toml b/config/_default/params.toml index fae6296..2c5ec5c 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -1,6 +1,6 @@ [main] - aosAssetsVersion = "4.0.1" - jctAssetsVersion = "4.0.1" + aosAssetsVersion = "4.0.2" + jctAssetsVersion = "4.0.2" feedbackButton = "Send us feedback" alert = "The information provided by the Journal Checker Tool represents cOAlition S’s current understanding in relation to the policies of the journals contained within it. We will endeavour to keep it up to date and accurate, but we do not accept any liability in relation to any errors or omissions." comingSoon = "Coming Soon" From b4ef8f2ce257b258a011a4c9e0457b162f045a1e Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Sun, 1 May 2022 21:01:39 +0100 Subject: [PATCH 6/7] applies some stop words to institutional searching, reduces the effective character length to 3, and improves the stop word stripping --- static/js/jct.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/static/js/jct.js b/static/js/jct.js index 49aa1f6..b119170 100644 --- a/static/js/jct.js +++ b/static/js/jct.js @@ -787,8 +787,12 @@ jct.d.toggle_detailed_results = () => { jct.suggest_prepare = (txt, stop_words) => { txt = txt.toLowerCase().trim(); for (let sw of stop_words) { - // FIXME: need to make the second and third only replace at the start and the end - txt = txt.replace(" " + sw + " ", " ").replace(sw + " ", "").replace(" " + sw, "") + let fullThing = new RegExp("^" + sw + "$"); + let atEnd = new RegExp(" " + sw + "$"); + let atStart = new RegExp("^" + sw + " "); + let inMiddle = new RegExp(" " + sw + " "); + + txt = txt.replace(fullThing, "").replace(atEnd, "").replace(atStart, "").replace(inMiddle, " ") } while (true) { if (!(txt.includes(" "))) { @@ -854,17 +858,14 @@ jct.setup = (manageUrl=true) => { let effectiveTextLength = text.length; let pattern = /[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9xX]/; if (!pattern.test(text)) { - // let effective_text = text.toLowerCase().replace(' of','').replace('the ',''); let effective_text = jct.suggest_prepare(text, ["of", "the", "and", "journa", "journal"]) - effectiveTextLength = effective_text.length - // text = text.toLowerCase().replace(' of','').replace('the ',''); + effectiveTextLength = effective_text.length; } - if (effectiveTextLength > 3) { + if (effectiveTextLength >= 3) { let ourcb = (xhr) => { let js = JSON.parse(xhr.response); callback(js.data); } - // jct.jx('suggest/journal/'+text, false, ourcb); jct.jx('suggest/journal/'+text, false, ourcb); } }, @@ -985,8 +986,9 @@ jct.setup = (manageUrl=true) => { autocomplete: "off" }, options : function(text, callback) { - text = text.toLowerCase(); //.replace(' of','').replace('the ',''); - if (text.length > 1) { + let effective_text = jct.suggest_prepare(text, ["of", "the", "and", "universi", "universit", "university"]) + let effectiveTextLength = effective_text.length; + if (effectiveTextLength >= 3) { let ourcb = (xhr) => { let js = JSON.parse(xhr.response); callback(js.data); From d0b1c848debcb5d3c4ecea28a6ff23a523adecb2 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Tue, 10 May 2022 14:15:38 +0100 Subject: [PATCH 7/7] fix issn reference for detailed results --- static/js/detailed_results.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/detailed_results.js b/static/js/detailed_results.js index ed0e928..ed69873 100644 --- a/static/js/detailed_results.js +++ b/static/js/detailed_results.js @@ -220,7 +220,7 @@ jct._yourQuery = (q) => { } } - let issns = jct.chosen.journal.issn.join(", "); + let issns = jct.chosen.journal.issns.join(", "); let publisher = jct.chosen.journal.publisher !== undefined ? jct.chosen.journal.publisher : jct.lang.explain.your_query.publisher_not_known; let journal = jct.lang.explain.your_query.journal_title_unknown;