From 6cd7599bd482904b8cc71f44c83d85d3b3af5daf Mon Sep 17 00:00:00 2001 From: Wayne Date: Fri, 9 Aug 2024 17:16:05 +0800 Subject: [PATCH] develop apha parser --- apha/manifest.json | 14 +++++++ apha/parser.js | 74 +++++++++++++++++++++++++++++++++++ apha/test/apha.2024-08-09.csv | 13 ++++++ 3 files changed, 101 insertions(+) create mode 100644 apha/manifest.json create mode 100755 apha/parser.js create mode 100644 apha/test/apha.2024-08-09.csv diff --git a/apha/manifest.json b/apha/manifest.json new file mode 100644 index 00000000..381210fb --- /dev/null +++ b/apha/manifest.json @@ -0,0 +1,14 @@ +{ + "longname": "APhA Pharmacy Library", + "name": "apha", + "describe": "Recognizes the accesses to the platform APhA Pharmacy Library", + "contact": "Violita Kovchegov", + "pkb": false, + "docurl": "https://analyses.ezpaarse.org/platforms/66b279634aa96e614c74a4bf", + "domains": [ + "pharmacylibrary.com", + "pharmacylibrary-com.jerome.stjohns.edu" + ], + "version": "2024-08-09", + "status": "beta" +} \ No newline at end of file diff --git a/apha/parser.js b/apha/parser.js new file mode 100755 index 00000000..1f62b7e2 --- /dev/null +++ b/apha/parser.js @@ -0,0 +1,74 @@ +#!/usr/bin/env node + +'use strict'; +const Parser = require('../.lib/parser.js'); + +/** + * Recognizes the accesses to the platform APhA Pharmacy Library + * @param {Object} parsedUrl an object representing the URL to analyze + * main attributes: pathname, query, hostname + * @param {Object} ec an object representing the EC whose URL is being analyzed + * @return {Object} the result + */ +module.exports = new Parser(function analyseEC(parsedUrl, ec) { + let result = {}; + let path = parsedUrl.pathname; + // uncomment this line if you need parameters + // let param = parsedUrl.query || {}; + + // use console.error for debuging + // console.error(parsedUrl); + + let match; + + if (/^\/action\/doSearch$/i.test(path)) { + // https://pharmacylibrary.com/action/doSearch?AllField=Acid+reflux + // https://pharmacylibrary.com/action/doSearch?AllField=HIV + result.rtype = 'SEARCH'; + result.mime = 'HTML'; + + } else if ((match = /^\/do\/[0-9.]+\/([a-zA-Z0-9._]+)\/full\/?$/i.exec(path)) !== null) { + // https://pharmacylibrary-com.jerome.stjohns.edu/do/10.21019/hap_vap_table_cap_dsm/full + // https://pharmacylibrary.com/do/10.21019/pharmacotherapyfirst.hiv_overview_table1/full + result.rtype = 'TABLE'; + result.mime = 'HTML'; + result.title_id = match[1]; + result.unitid = match[1]; + + } else if ((match = /^\/topic\/([a-zA-Z]+)$/i.exec(path)) !== null) { + // https://pharmacylibrary.com/topic/pfcbl + // https://pharmacylibrary.com/topic/multimedia + result.rtype = 'TOC'; + result.mime = 'HTML'; + result.unitid = match[1]; + } else if ((match = /^\/doi\/full\/([0-9.]+)\/([a-zA-Z0-9_.-]+)$/i.exec(path)) !== null) { + // https://pharmacylibrary.com/doi/full/10.21019/culturaltoolkit-diverse.cross-cultural_communication + result.rtype = 'BOOK'; + result.mime = 'HTML'; + result.title_id = match[2]; + result.unitid = `${match[1]}/${match[2]}`; + + } else if ((match = /^\/doi\/([0-9.]+)\/([a-zA-Z0-9_.-]+)$/i.exec(path)) !== null) { + // https://pharmacylibrary.com/doi/10.21019/culturaltoolkit-healthdisp.define_health-disp + // https://pharmacylibrary.com/doi/10.21019/ALE.2000.1 + result.rtype = 'BOOK'; + result.mime = 'HTML'; + result.title_id = match[2]; + result.unitid = `${match[1]}/${match[2]}`; + + } else if ((match = /^\/doi\/epub\/([0-9.]+)\/([0-9]+)$/i.exec(path)) !== null) { + // https://pharmacylibrary.com/doi/epub/10.21019/9781582122168 + // https://pharmacylibrary.com/doi/epub/10.21019/9781582122861 + result.rtype = 'BOOK'; + result.mime = 'EPUB'; + result.doi = `${match[1]}/${match[2]}`; + result.unitid = `${match[1]}/${match[2]}`; + } else if ((match = /^\/doi\/epdf\/([0-9.]+)\/([0-9]+)$/i.exec(path)) !== null) { + // https://pharmacylibrary.com/doi/epdf/10.21019/9781582121444 + result.rtype = 'BOOK'; + result.mime = 'PDF'; + result.doi = `${match[1]}/${match[2]}`; + result.unitid = `${match[1]}/${match[2]}`; + } + return result; +}); diff --git a/apha/test/apha.2024-08-09.csv b/apha/test/apha.2024-08-09.csv new file mode 100644 index 00000000..30039dd7 --- /dev/null +++ b/apha/test/apha.2024-08-09.csv @@ -0,0 +1,13 @@ +out-title_id;out-doi;out-unitid;out-rtype;out-mime;in-url +;10.21019/9781582122861;10.21019/9781582122861;BOOK;EPUB;https://pharmacylibrary.com/doi/epub/10.21019/9781582122861 +;10.21019/9781582121444;10.21019/9781582121444;BOOK;PDF;https://pharmacylibrary.com/doi/epdf/10.21019/9781582121444 +;10.21019/9781582122168;10.21019/9781582122168;BOOK;EPUB;https://pharmacylibrary.com/doi/epub/10.21019/9781582122168 +ALE.2000.1;;10.21019/ALE.2000.1;BOOK;HTML;https://pharmacylibrary.com/doi/10.21019/ALE.2000.1 +culturaltoolkit-diverse.cross-cultural_communication;;10.21019/culturaltoolkit-diverse.cross-cultural_communication;BOOK;HTML;https://pharmacylibrary.com/doi/full/10.21019/culturaltoolkit-diverse.cross-cultural_communication +culturaltoolkit-healthdisp.define_health-disp;;10.21019/culturaltoolkit-healthdisp.define_health-disp;BOOK;HTML;https://pharmacylibrary.com/doi/10.21019/culturaltoolkit-healthdisp.define_health-disp +;;pfcbl;TOC;HTML;https://pharmacylibrary.com/topic/pfcbl +;;multimedia;TOC;HTML;https://pharmacylibrary.com/topic/multimedia +hap_vap_table_cap_dsm;;hap_vap_table_cap_dsm;TABLE;HTML;https://pharmacylibrary-com.jerome.stjohns.edu/do/10.21019/hap_vap_table_cap_dsm/full/ +pharmacotherapyfirst.hiv_overview_table1;;pharmacotherapyfirst.hiv_overview_table1;TABLE;HTML;https://pharmacylibrary.com/do/10.21019/pharmacotherapyfirst.hiv_overview_table1/full/ +;;;SEARCH;HTML;https://pharmacylibrary.com/action/doSearch?AllField=Acid+reflux +;;;SEARCH;HTML;https://pharmacylibrary.com/action/doSearch?AllField=HIV \ No newline at end of file