Skip to content

Commit

Permalink
Small fixes for dedoc library (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
NastyBoget authored May 21, 2024
1 parent 29a0c0d commit ebb7593
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[![GitHub release](https://img.shields.io/github/release/ispras/dedoc.svg)](https://github.com/ispras/dedoc/releases/)
[![Demo dedoc-readme.hf.space](https://img.shields.io/website-up-down-green-red/https/huggingface.co/spaces/dedoc/README.svg)](https://dedoc-readme.hf.space)
[![Docker Hub](https://img.shields.io/docker/pulls/dedocproject/dedoc.svg)](https://hub.docker.com/r/dedocproject/dedoc/ "Docker Pulls")
[![CI tests](https://github.com/ispras/dedoc/workflows/CI/badge.svg)](https://github.com/ispras/dedoc/actions)

![Dedoc](https://github.com/ispras/dedoc/raw/master/dedoc_logo.png)

Expand Down
3 changes: 1 addition & 2 deletions dedoc/readers/article_reader/article_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def __init__(self, config: Optional[dict] = None) -> None:
self.grobid_url = f"http://{os.environ.get('GROBID_HOST', 'localhost')}:{os.environ.get('GROBID_PORT', '8070')}"
self.url = f"{self.grobid_url}/api/processFulltextDocument"
self.grobid_is_alive = False
self.__update_grobid_alive(self.grobid_url, max_attempts=self.config.get("grobid_max_connection_attempts", 3))

def read(self, file_path: str, parameters: Optional[dict] = None) -> UnstructuredDocument:
"""
Expand Down Expand Up @@ -91,7 +90,7 @@ def can_read(self, file_path: Optional[str] = None, mime: Optional[str] = None,
if get_param_document_type(parameters) != "article":
return False

self.__update_grobid_alive(self.grobid_url, max_attempts=1)
self.__update_grobid_alive(self.grobid_url, max_attempts=self.config.get("grobid_max_connection_attempts", 3))
if not self.grobid_is_alive:
return False

Expand Down
2 changes: 1 addition & 1 deletion dedoc/utils/parameter_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,6 @@ def get_param_attachments_dir(parameters: Optional[dict], file_path: str) -> str
parameters = {} if parameters is None else parameters

attachments_dir = parameters.get("attachments_dir", None)
attachments_dir = default_dir if attachments_dir is None else attachments_dir
attachments_dir = attachments_dir if attachments_dir else default_dir
os.makedirs(attachments_dir, exist_ok=True)
return attachments_dir

0 comments on commit ebb7593

Please sign in to comment.