Skip to content

Commit

Permalink
add (Pss-System.js) 新增国家知识产权局专利检索及分析系统
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaojiaodubai committed May 8, 2024
1 parent f32d46e commit 9132cc5
Show file tree
Hide file tree
Showing 2 changed files with 196 additions and 0 deletions.
195 changes: 195 additions & 0 deletions Pss-System.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
{
"translatorID": "f1002463-6769-4004-948d-b14579a8c2f5",
"label": "Pss-System",
"creator": "jiaojiaodubai",
"target": "^https://pss-system\\.cponline\\.cnipa\\.gov\\.cn",
"minVersion": "5.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2024-05-08 04:00:06"
}

/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2024 jiaojiaodubai<jiaojiaodubai23@gmail.com>
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/


function detectWeb(doc, url) {
return url.includes('/detail?') && doc.querySelector('.activeli:first-child')
? 'patent'
: false;
}

async function doWeb(doc, _url) {
const newItem = new Z.Item('patent');
const labels = new LabelsX(doc, '.basic-con');
const extra = new Extra();
newItem.title = ZU.capitalizeTitle(labels.getWith(['发明名称$', 'InventionTitle']));
extra.set('original-title', labels.getWith(['发明名称(原始国)', 'InventionTitle\\(Originalcountry\\)']), true);
newItem.abstractNote = labels.getWith(['摘要', 'Abstract']);
newItem.place = newItem.country = patentCountry(labels.getWith(['申请人所在国家', "Applicant'scountry"]));
newItem.assignee = ZU.capitalizeName(labels.getWith(['申请(专利权)人', 'Applicant/Patentee']));
newItem.patentNumber = labels.getWith(['公开(公告)号', 'PublicNoticeNo']);
newItem.filingDate = ZU.strToISO(labels.getWith(['申请日', 'ApplicationDate']));
newItem.applicationNumber = labels.getWith(['申请号', 'ApplicationNo']);
newItem.priorityNumbers = labels.getWith(['优先权号', 'PriorityNo']);
newItem.issueDate = ZU.strToISO(labels.getWith(['公开(公告)日', 'PublicationDate']));
extra.set('IPC', labels.getWith('IPC'));
extra.set('CPC', labels.getWith('CPC'));
newItem.creators = labels.getWith(['发明人', 'Inventor']).split(/;\s/).map((string) => {
const creator = ZU.cleanAuthor(ZU.capitalizeName(string), 'inventor');
if (/[\u4e00-\u9fff]/.test(creator.lastName)) {
creator.lastName = creator.firstName + creator.lastName;
creator.fieldMode = 1;
}
return creator;
});
newItem.attachments.push({
title: 'Snapshot',
document: doc
});
newItem.extra = extra.toString();
newItem.complete();
}

class LabelsX {
constructor(doc, selector) {
this.innerData = [];
this.emptyElement = doc.createElement('div');
Array.from(doc.querySelectorAll(selector))
// avoid nesting
.filter(element => !element.querySelector(selector))
// avoid empty
.filter(element => !/^\s*$/.test(element.textContent))
.forEach((element) => {
let elementCopy = element.cloneNode(true);
// avoid empty text
while (/^\s*$/.test(elementCopy.firstChild.textContent)) {
// Z.debug(elementCopy.firstChild.textContent);
elementCopy.removeChild(elementCopy.firstChild);
// Z.debug(elementCopy.firstChild.textContent);
}
if (elementCopy.childNodes.length > 1) {
let key = elementCopy.removeChild(elementCopy.firstChild).textContent.replace(/\s/g, '');
this.innerData.push([key, elementCopy]);
}
else {
let text = ZU.trimInternal(elementCopy.textContent);
let key = tryMatch(text, /^[[【]?.+?[】\]::]/).replace(/\s/g, '');
elementCopy.textContent = tryMatch(text, /^[[【]?.+?[】\]::]\s*(.+)/, 1);
this.innerData.push([key, elementCopy]);
}
});
}

getWith(label, element = false) {
if (Array.isArray(label)) {
let results = label
.map(aLabel => this.getWith(aLabel, element));
let keyVal = element
? results.find(element => !/^\s*$/.test(element.textContent))
: results.find(string => string);
return keyVal
? keyVal
: element
? this.emptyElement
: '';
}
let pattern = new RegExp(label, 'i');
let keyVal = this.innerData.find(arr => pattern.test(arr[0]));
return keyVal
? element
? keyVal[1]
: ZU.trimInternal(keyVal[1].textContent)
: element
? this.emptyElement
: '';
}
}

class Extra {
constructor() {
this.fields = [];
}

push(key, val, csl = false) {
this.fields.push({ key: key, val: val, csl: csl });
}

set(key, val, csl = false) {
let target = this.fields.find(obj => new RegExp(`^${key}$`, 'i').test(obj.key));
if (target) {
target.val = val;
}
else {
this.push(key, val, csl);
}
}

get(key) {
let result = this.fields.find(obj => new RegExp(`^${key}$`, 'i').test(obj.key));
return result
? result.val
: '';
}

toString(history = '') {
this.fields = this.fields.filter(obj => obj.val);
return [
this.fields.filter(obj => obj.csl).map(obj => `${obj.key}: ${obj.val}`).join('\n'),
history,
this.fields.filter(obj => !obj.csl).map(obj => `${obj.key}: ${obj.val}`).join('\n')
].filter(obj => obj).join('\n');
}
}

/**
* Attempts to get the part of the pattern described from the character,
* and returns an empty string if not match.
* @param {String} string
* @param {RegExp} pattern
* @param {Number} index
* @returns
*/
function tryMatch(string, pattern, index = 0) {
if (!string) return '';
let match = string.match(pattern);
return (match && match[index])
? match[index]
: '';
}

function patentCountry(idNumber) {
return {
AD: '安道尔', AE: '阿拉伯联合酋长国', AF: '阿富汗', AG: '安提瓜和巴布达', AI: '安圭拉', AL: '阿尔巴尼亚', AM: '亚美尼亚', AN: '菏属安的列斯群岛', AO: '安哥拉', AR: '阿根廷', AT: '奥地利', AU: '澳大利亚', AW: '阿鲁巴', AZ: '阿塞拜疆', BB: '巴巴多斯', BD: '孟加拉国', BE: '比利时', BF: '布莱基纳法索', BG: '保加利亚', BH: '巴林', BI: '布隆迪', BJ: '贝宁', BM: '百慕大', BN: '文莱', BO: '玻利维亚', BR: '巴西', BS: '巴哈马', BT: '不丹', BU: '缅甸', BW: '博茨瓦纳', BY: '白俄罗斯', BZ: '伯利兹', CA: '加拿大', CF: '中非共和国', CG: '刚果', CH: '瑞士', CI: '科特迪瓦', CL: '智利', CM: '喀麦隆', CN: '中国', CO: '哥伦比亚', CR: '哥斯达黎加', CS: '捷克斯洛伐克', CU: '古巴', CV: '怫得角', CY: '塞浦路斯',
DE: '联邦德国', DJ: '吉布提', DK: '丹麦', DM: '多米尼加岛', DO: '多米尼加共和国', DZ: '阿尔及利亚', EC: '厄瓜多尔', EE: '爱沙尼亚', EG: '埃及', EP: '欧洲专利局', ES: '西班牙', ET: '埃塞俄比亚', FI: '芬兰', FJ: '斐济', FK: '马尔维纳斯群岛', FR: '法国',
GA: '加蓬', GB: '英国', GD: '格林那达', GE: '格鲁吉亚', GH: '加纳', GI: '直布罗陀', GM: '冈比亚', GN: '几内亚', GQ: '赤道几内亚', GR: '希腊', GT: '危地马拉', GW: '几内亚比绍', GY: '圭亚那', HK: '香港', HN: '洪都拉斯', HR: '克罗地亚', HT: '海地', HU: '匈牙利', HV: '上沃尔特', ID: '印度尼西亚', IE: '爱尔兰', IL: '以色列', IN: '印度', IQ: '伊拉克', IR: '伊朗', IS: '冰岛', IT: '意大利',
JE: '泽西岛', JM: '牙买加', JO: '约旦', JP: '日本', KE: '肯尼亚', KG: '吉尔吉斯', KH: '柬埔寨', KI: '吉尔伯特群岛', KM: '科摩罗', KN: '圣克里斯托夫岛', KP: '朝鲜', KR: '韩国', KW: '科威特', KY: '开曼群岛', KZ: '哈萨克', LA: '老挝', LB: '黎巴嫩', LC: '圣卢西亚岛', LI: '列支敦士登', LK: '斯里兰卡', LR: '利比里亚', LS: '莱索托', LT: '立陶宛', LU: '卢森堡', LV: '拉脱维亚', LY: '利比亚',
MA: '摩洛哥', MC: '摩纳哥', MD: '莫尔多瓦', MG: '马达加斯加', ML: '马里', MN: '蒙古', MO: '澳门', MR: '毛里塔尼亚', MS: '蒙特塞拉特岛', MT: '马耳他', MU: '毛里求斯', MV: '马尔代夫', MW: '马拉维', MX: '墨西哥', MY: '马来西亚', MZ: '莫桑比克', NA: '纳米比亚', NE: '尼日尔', NG: '尼日利亚', NH: '新赫布里底', NI: '尼加拉瓜', NL: '荷兰', NO: '挪威', NP: '尼泊尔', NR: '瑙鲁', NZ: '新西兰', OA: '非洲知识产权组织', OM: '阿曼',
PA: '巴拿马', PC: 'PCT', PE: '秘鲁', PG: '巴布亚新几内亚', PH: '菲律宾', PK: '巴基斯坦', PL: '波兰', PT: '葡萄牙', PY: '巴拉圭', QA: '卡塔尔', RO: '罗马尼亚', RU: '俄罗斯联邦', RW: '卢旺达',
SA: '沙特阿拉伯', SB: '所罗门群岛', SC: '塞舌尔', SD: '苏丹', SE: '瑞典', SG: '新加坡', SH: '圣赫勒拿岛', SI: '斯洛文尼亚', SL: '塞拉利昂', SM: '圣马利诺', SN: '塞内加尔', SO: '索马里', SR: '苏里南', ST: '圣多美和普林西比岛', SU: '苏联', SV: '萨尔瓦多', SY: '叙利亚', SZ: '斯威士兰', TD: '乍得', TG: '多哥', TH: '泰国', TJ: '塔吉克', TM: '土库曼', TN: '突尼斯', TO: '汤加', TR: '土耳其', TT: '特立尼达和多巴哥', TV: '图瓦卢', TZ: '坦桑尼亚', UA: '乌克兰', UG: '乌干达', US: '美国', UY: '乌拉圭', UZ: '乌兹别克',
VA: '梵蒂冈', VC: '圣文森特岛和格林纳达', VE: '委内瑞拉', VG: '维尔京群岛', VN: '越南', VU: '瓦努阿图', WO: '世界知识产权组织', WS: '萨摩亚', YD: '民主也门', YE: '也门', YU: '南斯拉夫', ZA: '南非', ZM: '赞比亚', ZR: '扎伊尔', ZW: '津巴布韦'
}[idNumber.substring(0, 2).toUpperCase()] || '';
}
1 change: 1 addition & 0 deletions data/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"Pishu Data": "皮书数据库",
"PKULaw": "北大法宝",
"ProQuestCN Thesis": "ProQuest学位论文(中国)",
"Pss-System": "国家知识产权局专利检索及分析系统",
"Publications Data Center - China": "国家版本馆版权数据中心",
"PubScholar": "PubScholar公益学术平台",
"QStheory": "求是网",
Expand Down

0 comments on commit 9132cc5

Please sign in to comment.