Skip to content

Commit ff7661e

Browse files
committed
Add param about patent item
1 parent 2eea491 commit ff7661e

2 files changed

Lines changed: 7 additions & 16 deletions

File tree

refparse/wos.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44

55
class ParseWos:
6-
def __init__(self, ref: str, keep_one_doi: bool = True, keep_eng_result: bool = True):
6+
def __init__(self, ref: str, keep_one_doi: bool = True, keep_eng_result: bool = True, ignore_patent: bool = True):
77
self.ref = self.clean(ref)
88
self.keep_one_doi = keep_one_doi
99
self.keep_eng_result = keep_eng_result
10+
self.ignore_patent = ignore_patent
1011

1112
@staticmethod
1213
def clean(ref: str) -> str:
@@ -22,7 +23,8 @@ def parse(self):
2223
if self.ref.startswith("[Anonymous]"):
2324
return None
2425
elif "Patent No." in self.ref:
25-
return self.parse_patent()
26+
if not self.ignore_patent:
27+
return self.parse_patent()
2628
elif re.search(r"\d{4}, \[", self.ref):
2729
return self.parse_bilingual()
2830
else:
@@ -166,7 +168,6 @@ def parse_patent(self) -> dict[str, Optional[str]]:
166168
title = None
167169

168170
return {
169-
"type": "Patent",
170171
"author": author,
171172
"year": year,
172173
"patent_title": title,

tests/test_wos.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,15 @@
102102
test_patent_data = [
103103
(
104104
"Fan P., 2011, PT, Patent No. 2011163640",
105-
{"type": "Patent", "author": "Fan P.", "year": "2011", "patent_title": None, "patent_number": "2011163640"},
105+
{"author": "Fan P.", "year": "2011", "patent_title": None, "patent_number": "2011163640"},
106106
),
107107
(
108108
"Redlich R. M., 2006, U. S. Patent, Patent No. [7,103,915, 7103915]",
109-
{"type": "Patent", "author": "Redlich R. M.", "year": "2006", "patent_title": None, "patent_number": "7103915"},
109+
{"author": "Redlich R. M.", "year": "2006", "patent_title": None, "patent_number": "7103915"},
110110
),
111111
(
112112
"Watanabe K., 1995, Low calorie foodstuff, aqueous paste composition, as well as production process thereof, Patent No. 5690981A",
113113
{
114-
"type": "Patent",
115114
"author": "Watanabe K.",
116115
"year": "1995",
117116
"patent_title": "Low calorie foodstuff, aqueous paste composition, as well as production process thereof",
@@ -122,16 +121,7 @@
122121

123122
test_parse_data = [
124123
("[Anonymous], 2017, NATURE, DOI DOI 10.1038/NATURE.2017.22094", None),
125-
(
126-
"Dodd SK., 2013, Patent No. 2013/171639 A1",
127-
{
128-
"type": "Patent",
129-
"author": "Dodd SK.",
130-
"year": "2013",
131-
"patent_title": None,
132-
"patent_number": "2013/171639 A1",
133-
},
134-
),
124+
("Dodd SK., 2013, Patent No. 2013/171639 A1", None),
135125
(
136126
"Wang X, 2019, BIOINFORMATICS, V35, P1745, DOI 10.1093/bioinformatics/bty869",
137127
{

0 commit comments

Comments
 (0)