-
Notifications
You must be signed in to change notification settings - Fork 924
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add PATENT_USPTO as input format
Signed-off-by: Cesar Berrospi Ramis <[email protected]>
- Loading branch information
Showing
3 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""Backend to parse patents from the United States Patent Office (USPTO). | ||
The parsers included in this module can handle patent grants pubished since 1976 and | ||
patent applications since 2001. | ||
The original files can be found in https://bulkdata.uspto.gov. | ||
""" | ||
|
||
import logging | ||
from io import BytesIO | ||
from pathlib import Path | ||
from typing import Union | ||
|
||
from docling_core.types.doc import DoclingDocument | ||
|
||
from docling.backend.abstract_backend import DeclarativeDocumentBackend | ||
from docling.datamodel.base_models import InputFormat | ||
from docling.datamodel.document import InputDocument | ||
|
||
_log = logging.getLogger(__name__) | ||
|
||
|
||
class PatentUsptoDocumentBackend(DeclarativeDocumentBackend): | ||
def __init__(self, in_doc: InputDocument, path_or_stream: Union[BytesIO, Path]): | ||
super().__init__(in_doc, path_or_stream) | ||
|
||
return | ||
|
||
def is_valid(self) -> bool: | ||
return False | ||
|
||
@classmethod | ||
def supports_pagination(cls) -> bool: | ||
return False | ||
|
||
def unload(self): | ||
return | ||
|
||
@classmethod | ||
def supported_formats(cls) -> set[InputFormat]: | ||
return {InputFormat.PATENT_USPTO} | ||
|
||
def convert(self) -> DoclingDocument: | ||
doc = DoclingDocument(name=self.file.stem or "file") | ||
|
||
return doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters