Skip to content

Commit

Permalink
Add classification for software
Browse files Browse the repository at this point in the history
  • Loading branch information
physikerwelt committed Oct 17, 2024
1 parent ef4afa8 commit 1936ce7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/zbmath_rest2oai/getAsXml.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ def apply_zbmath_api_fixes(result, prefix):


def extract_tags(result):
mscs = result.get('msc', [])
tags = []
for msc in mscs:
for msc in result.get('msc', []):
msc0 = msc['code'][:2]
if msc0 not in tags:
tags.append(msc0)
for msc in result.get('classification', []):
if msc not in tags:
tags.append(msc)
tags.sort()
if result.get('database') == 'JFM':
tags.append('JFM')
Expand Down
18 changes: 13 additions & 5 deletions test/test_extract_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,24 @@

from zbmath_rest2oai.getAsXml import extract_tags

API_SOURCE = 'https://api.zbmath.org/v1/document/_structured_search?page=0&results_per_page=10&zbmath%20id=2500495'


class PlainXmlTest(unittest.TestCase):
def test_similarity(self):
@staticmethod
def test_jfm_doc():
headers = {'Accept': 'application/json'}
r = requests.get(API_SOURCE, headers=headers)
r = requests.get(
'https://api.zbmath.org/v1/document/_structured_search?page=0&results_per_page=10&zbmath%20id=2500495',
headers=headers)
real_tags = extract_tags(r.json()['result'][0])
assert real_tags == ['11', 'JFM']

@staticmethod
def test_software():
headers = {'Accept': 'application/json'}
r = requests.get(
'https://api.zbmath.org/v1/software/12',
headers=headers)
real_tags = extract_tags(r.json()['result'])
assert real_tags == ['60', '65', '78', '82']

if __name__ == '__main__':
unittest.main()

0 comments on commit 1936ce7

Please sign in to comment.