Skip to content
This repository was archived by the owner on Jan 29, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/bluesearch/database/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
import string
import unicodedata
from abc import ABC, abstractmethod
from dataclasses import dataclass
from dataclasses import dataclass, field
from io import StringIO
from pathlib import Path
from typing import IO, Generator, Iterable, Optional, Sequence, Tuple
from typing import IO, Dict, Generator, Iterable, List, Optional, Sequence, Tuple
from xml.etree.ElementTree import Element # nosec
from zipfile import ZipFile

Expand Down Expand Up @@ -1071,6 +1071,7 @@ class Article(DataClassJSONMixin):
arxiv_id: Optional[str] = None
doi: Optional[str] = None
uid: Optional[str] = None
topics: Dict[str, Dict[str, List[str]]] = field(default_factory=dict)

@classmethod
def parse(cls, parser: ArticleParser) -> Article:
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/database/test_article.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,11 @@ def test_parse(self):
):
assert text == text_want

assert article.topics == {}
test_dict = {"article": {"topic_type": ["this", "is", "a", "list"]}}
article.topics.update(test_dict)
assert article.topics == test_dict

def test_str(self):
parser = SimpleTestParser()
article = Article.parse(parser)
Expand Down