1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//! # grobid
//!
//! A native Rust client for the [GROBID](https://grobid.readthedocs.io/)
//! REST API, with a strongly typed parser for GROBID TEI documents.
//!
//! GROBID is a machine learning library for extracting, parsing and
//! re-structuring raw documents such as PDFs into structured TEI-XML. This
//! crate provides:
//!
//! * an asynchronous HTTP client ([`GrobidClient`]) for the GROBID web
//! services, with busy-server retries,
//! * a TEI parser that turns GROBID responses into strongly typed Rust
//! structures ([`Document`], [`Biblio`], [`Citation`], ...), exposing the
//! full document hierarchy, bibliographic metadata, references and
//! optional PDF coordinates,
//! * optional second-tier completion of parsed references against OpenAlex
//! (`openalex` feature).
//!
//! BibTeX/BibLaTeX rendering and bibliography tooling moved to the
//! companion crate [`grobid-bibtex`](https://crates.io/crates/grobid-bibtex),
//! together with the `pdf2bibtex` and `refs2bibtex` command-line tools.
//!
//! ## Example
//!
//! ```no_run
//! use grobid::{GrobidClient, ProcessOptions};
//!
//! # async fn run() -> Result<(), grobid::Error> {
//! let client = GrobidClient::new("http://localhost:8070")?;
//! assert!(client.ping().await?);
//!
//! // Process a PDF and inspect the parsed TEI.
//! let document = client
//! .process_fulltext_document("paper.pdf", &ProcessOptions::default())
//! .await?;
//! println!("title: {:?}", document.header.title);
//! println!("authors: {}", document.header.authors.len());
//! println!("citations: {}", document.citations.len());
//!
//! for section in &document.body {
//! println!("## {}", section.head.as_deref().unwrap_or("(untitled)"));
//! for paragraph in section.paragraphs() {
//! println!("{}", paragraph.text);
//! }
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ## Parsing TEI without a server
//!
//! The parser works on TEI XML obtained elsewhere, e.g. written to disk by
//! a batch process:
//!
//! ```
//! use grobid::tei::parse_document;
//!
//! let xml = r#"<TEI xmlns="http://www.tei-c.org/ns/1.0">
//! <teiHeader>
//! <encodingDesc><appInfo>
//! <application version="0.8.1" when="2024-01-01T00:00+0000"/>
//! </appInfo></encodingDesc>
//! <fileDesc>
//! <titleStmt><title level="a" type="main">Example</title></titleStmt>
//! <publicationStmt><publisher/></publicationStmt>
//! <sourceDesc><biblStruct/></sourceDesc>
//! </fileDesc>
//! </teiHeader>
//! <text/>
//! </TEI>"#;
//!
//! let document = parse_document(xml)?;
//! assert_eq!(document.header.title.as_deref(), Some("Example"));
//! # Ok::<(), grobid::Error>(())
//! ```
//!
//! The full README is included below.
//!
pub use ;
pub use ;
pub use ;