scholaris-sdk 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. scholaris_sdk-2.0.0/LICENSE +190 -0
  2. scholaris_sdk-2.0.0/PKG-INFO +168 -0
  3. scholaris_sdk-2.0.0/README.md +118 -0
  4. scholaris_sdk-2.0.0/pyproject.toml +81 -0
  5. scholaris_sdk-2.0.0/scholaris/__init__.py +48 -0
  6. scholaris_sdk-2.0.0/scholaris/api.py +165 -0
  7. scholaris_sdk-2.0.0/scholaris/auto_cite/__init__.py +113 -0
  8. scholaris_sdk-2.0.0/scholaris/auto_cite/citation_engine.py +1695 -0
  9. scholaris_sdk-2.0.0/scholaris/auto_cite/citation_export.py +349 -0
  10. scholaris_sdk-2.0.0/scholaris/auto_cite/citation_index.py +1263 -0
  11. scholaris_sdk-2.0.0/scholaris/auto_cite/document_formats.py +671 -0
  12. scholaris_sdk-2.0.0/scholaris/auto_cite/formatters.py +347 -0
  13. scholaris_sdk-2.0.0/scholaris/auto_cite/metadata_extractor.py +649 -0
  14. scholaris_sdk-2.0.0/scholaris/auto_cite/models.py +430 -0
  15. scholaris_sdk-2.0.0/scholaris/auto_cite/orchestrator.py +979 -0
  16. scholaris_sdk-2.0.0/scholaris/auto_cite/page_aware_rag.py +548 -0
  17. scholaris_sdk-2.0.0/scholaris/auto_cite/page_offset.py +826 -0
  18. scholaris_sdk-2.0.0/scholaris/auto_cite/pdf_processor.py +344 -0
  19. scholaris_sdk-2.0.0/scholaris/auto_cite/processed_pdf.py +815 -0
  20. scholaris_sdk-2.0.0/scholaris/auto_cite/rag_engine.py +579 -0
  21. scholaris_sdk-2.0.0/scholaris/auto_cite/validate_page_detection.py +384 -0
  22. scholaris_sdk-2.0.0/scholaris/auto_cite/vision_ocr.py +768 -0
  23. scholaris_sdk-2.0.0/scholaris/cli.py +648 -0
  24. scholaris_sdk-2.0.0/scholaris/config.py +117 -0
  25. scholaris_sdk-2.0.0/scholaris/converters/__init__.py +5 -0
  26. scholaris_sdk-2.0.0/scholaris/converters/bibtex_parser.py +165 -0
  27. scholaris_sdk-2.0.0/scholaris/converters/docx_converter.py +344 -0
  28. scholaris_sdk-2.0.0/scholaris/converters/html_converter.py +236 -0
  29. scholaris_sdk-2.0.0/scholaris/core/__init__.py +0 -0
  30. scholaris_sdk-2.0.0/scholaris/core/citation.py +177 -0
  31. scholaris_sdk-2.0.0/scholaris/core/models.py +195 -0
  32. scholaris_sdk-2.0.0/scholaris/core/review.py +347 -0
  33. scholaris_sdk-2.0.0/scholaris/exceptions.py +61 -0
  34. scholaris_sdk-2.0.0/scholaris/providers/__init__.py +0 -0
  35. scholaris_sdk-2.0.0/scholaris/providers/base.py +76 -0
  36. scholaris_sdk-2.0.0/scholaris/providers/bibtex/__init__.py +0 -0
  37. scholaris_sdk-2.0.0/scholaris/providers/bibtex/base.py +32 -0
  38. scholaris_sdk-2.0.0/scholaris/providers/bibtex/llm_fallback.py +92 -0
  39. scholaris_sdk-2.0.0/scholaris/providers/bibtex/pdf2bib.py +100 -0
  40. scholaris_sdk-2.0.0/scholaris/providers/llm/__init__.py +25 -0
  41. scholaris_sdk-2.0.0/scholaris/providers/llm/base.py +74 -0
  42. scholaris_sdk-2.0.0/scholaris/providers/llm/deepseek.py +171 -0
  43. scholaris_sdk-2.0.0/scholaris/providers/llm/gemini.py +267 -0
  44. scholaris_sdk-2.0.0/scholaris/providers/llm/perplexity.py +179 -0
  45. scholaris_sdk-2.0.0/scholaris/providers/search/__init__.py +0 -0
  46. scholaris_sdk-2.0.0/scholaris/providers/search/base.py +52 -0
  47. scholaris_sdk-2.0.0/scholaris/providers/search/pypaperbot.py +238 -0
  48. scholaris_sdk-2.0.0/scholaris/scholaris.py +718 -0
  49. scholaris_sdk-2.0.0/scholaris/utils/__init__.py +0 -0
  50. scholaris_sdk-2.0.0/scholaris/utils/logging.py +44 -0
  51. scholaris_sdk-2.0.0/scholaris/utils/rate_limiter.py +70 -0
  52. scholaris_sdk-2.0.0/scholaris/v2/__init__.py +9 -0
  53. scholaris_sdk-2.0.0/scholaris/v2/api.py +475 -0
  54. scholaris_sdk-2.0.0/scholaris/v2/citas.py +58 -0
  55. scholaris_sdk-2.0.0/scholaris/v2/spdf4.py +257 -0
  56. scholaris_sdk-2.0.0/scholaris_sdk.egg-info/PKG-INFO +168 -0
  57. scholaris_sdk-2.0.0/scholaris_sdk.egg-info/SOURCES.txt +60 -0
  58. scholaris_sdk-2.0.0/scholaris_sdk.egg-info/dependency_links.txt +1 -0
  59. scholaris_sdk-2.0.0/scholaris_sdk.egg-info/entry_points.txt +2 -0
  60. scholaris_sdk-2.0.0/scholaris_sdk.egg-info/requires.txt +22 -0
  61. scholaris_sdk-2.0.0/scholaris_sdk.egg-info/top_level.txt +1 -0
  62. scholaris_sdk-2.0.0/setup.cfg +4 -0
@@ -0,0 +1,190 @@
1
+ EUROPEAN UNION PUBLIC LICENCE v. 1.2
2
+ EUPL © the European Union 2007, 2016
3
+
4
+ This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined below) which is provided under the
5
+ terms of this Licence. Any use of the Work, other than as authorised under this Licence is prohibited (to the extent such
6
+ use is covered by a right of the copyright holder of the Work).
7
+ The Work is provided under the terms of this Licence when the Licensor (as defined below) has placed the following
8
+ notice immediately following the copyright notice for the Work:
9
+ Licensed under the EUPL
10
+ or has expressed by any other means his willingness to license under the EUPL.
11
+
12
+ 1.Definitions
13
+ In this Licence, the following terms have the following meaning:
14
+ — ‘The Licence’:this Licence.
15
+ — ‘The Original Work’:the work or software distributed or communicated by the Licensor under this Licence, available
16
+ as Source Code and also as Executable Code as the case may be.
17
+ — ‘Derivative Works’:the works or software that could be created by the Licensee, based upon the Original Work or
18
+ modifications thereof. This Licence does not define the extent of modification or dependence on the Original Work
19
+ required in order to classify a work as a Derivative Work; this extent is determined by copyright law applicable in
20
+ the country mentioned in Article 15.
21
+ — ‘The Work’:the Original Work or its Derivative Works.
22
+ — ‘The Source Code’:the human-readable form of the Work which is the most convenient for people to study and
23
+ modify.
24
+ — ‘The Executable Code’:any code which has generally been compiled and which is meant to be interpreted by
25
+ a computer as a program.
26
+ — ‘The Licensor’:the natural or legal person that distributes or communicates the Work under the Licence.
27
+ — ‘Contributor(s)’:any natural or legal person who modifies the Work under the Licence, or otherwise contributes to
28
+ the creation of a Derivative Work.
29
+ — ‘The Licensee’ or ‘You’:any natural or legal person who makes any usage of the Work under the terms of the
30
+ Licence.
31
+ — ‘Distribution’ or ‘Communication’:any act of selling, giving, lending, renting, distributing, communicating,
32
+ transmitting, or otherwise making available, online or offline, copies of the Work or providing access to its essential
33
+ functionalities at the disposal of any other natural or legal person.
34
+
35
+ 2.Scope of the rights granted by the Licence
36
+ The Licensor hereby grants You a worldwide, royalty-free, non-exclusive, sublicensable licence to do the following, for
37
+ the duration of copyright vested in the Original Work:
38
+ — use the Work in any circumstance and for all usage,
39
+ — reproduce the Work,
40
+ — modify the Work, and make Derivative Works based upon the Work,
41
+ — communicate to the public, including the right to make available or display the Work or copies thereof to the public
42
+ and perform publicly, as the case may be, the Work,
43
+ — distribute the Work or copies thereof,
44
+ — lend and rent the Work or copies thereof,
45
+ — sublicense rights in the Work or copies thereof.
46
+ Those rights can be exercised on any media, supports and formats, whether now known or later invented, as far as the
47
+ applicable law permits so.
48
+ In the countries where moral rights apply, the Licensor waives his right to exercise his moral right to the extent allowed
49
+ by law in order to make effective the licence of the economic rights here above listed.
50
+ The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to any patents held by the Licensor, to the
51
+ extent necessary to make use of the rights granted on the Work under this Licence.
52
+
53
+ 3.Communication of the Source Code
54
+ The Licensor may provide the Work either in its Source Code form, or as Executable Code. If the Work is provided as
55
+ Executable Code, the Licensor provides in addition a machine-readable copy of the Source Code of the Work along with
56
+ each copy of the Work that the Licensor distributes or indicates, in a notice following the copyright notice attached to
57
+ the Work, a repository where the Source Code is easily and freely accessible for as long as the Licensor continues to
58
+ distribute or communicate the Work.
59
+
60
+ 4.Limitations on copyright
61
+ Nothing in this Licence is intended to deprive the Licensee of the benefits from any exception or limitation to the
62
+ exclusive rights of the rights owners in the Work, of the exhaustion of those rights or of other applicable limitations
63
+ thereto.
64
+
65
+ 5.Obligations of the Licensee
66
+ The grant of the rights mentioned above is subject to some restrictions and obligations imposed on the Licensee. Those
67
+ obligations are the following:
68
+
69
+ Attribution right: The Licensee shall keep intact all copyright, patent or trademarks notices and all notices that refer to
70
+ the Licence and to the disclaimer of warranties. The Licensee must include a copy of such notices and a copy of the
71
+ Licence with every copy of the Work he/she distributes or communicates. The Licensee must cause any Derivative Work
72
+ to carry prominent notices stating that the Work has been modified and the date of modification.
73
+
74
+ Copyleft clause: If the Licensee distributes or communicates copies of the Original Works or Derivative Works, this
75
+ Distribution or Communication will be done under the terms of this Licence or of a later version of this Licence unless
76
+ the Original Work is expressly distributed only under this version of the Licence — for example by communicating
77
+ ‘EUPL v. 1.2 only’. The Licensee (becoming Licensor) cannot offer or impose any additional terms or conditions on the
78
+ Work or Derivative Work that alter or restrict the terms of the Licence.
79
+
80
+ Compatibility clause: If the Licensee Distributes or Communicates Derivative Works or copies thereof based upon both
81
+ the Work and another work licensed under a Compatible Licence, this Distribution or Communication can be done
82
+ under the terms of this Compatible Licence. For the sake of this clause, ‘Compatible Licence’ refers to the licences listed
83
+ in the appendix attached to this Licence. Should the Licensee's obligations under the Compatible Licence conflict with
84
+ his/her obligations under this Licence, the obligations of the Compatible Licence shall prevail.
85
+
86
+ Provision of Source Code: When distributing or communicating copies of the Work, the Licensee will provide
87
+ a machine-readable copy of the Source Code or indicate a repository where this Source will be easily and freely available
88
+ for as long as the Licensee continues to distribute or communicate the Work.
89
+ Legal Protection: This Licence does not grant permission to use the trade names, trademarks, service marks, or names
90
+ of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and
91
+ reproducing the content of the copyright notice.
92
+
93
+ 6.Chain of Authorship
94
+ The original Licensor warrants that the copyright in the Original Work granted hereunder is owned by him/her or
95
+ licensed to him/her and that he/she has the power and authority to grant the Licence.
96
+ Each Contributor warrants that the copyright in the modifications he/she brings to the Work are owned by him/her or
97
+ licensed to him/her and that he/she has the power and authority to grant the Licence.
98
+ Each time You accept the Licence, the original Licensor and subsequent Contributors grant You a licence to their contributions
99
+ to the Work, under the terms of this Licence.
100
+
101
+ 7.Disclaimer of Warranty
102
+ The Work is a work in progress, which is continuously improved by numerous Contributors. It is not a finished work
103
+ and may therefore contain defects or ‘bugs’ inherent to this type of development.
104
+ For the above reason, the Work is provided under the Licence on an ‘as is’ basis and without warranties of any kind
105
+ concerning the Work, including without limitation merchantability, fitness for a particular purpose, absence of defects or
106
+ errors, accuracy, non-infringement of intellectual property rights other than copyright as stated in Article 6 of this
107
+ Licence.
108
+ This disclaimer of warranty is an essential part of the Licence and a condition for the grant of any rights to the Work.
109
+
110
+ 8.Disclaimer of Liability
111
+ Except in the cases of wilful misconduct or damages directly caused to natural persons, the Licensor will in no event be
112
+ liable for any direct or indirect, material or moral, damages of any kind, arising out of the Licence or of the use of the
113
+ Work, including without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, loss
114
+ of data or any commercial damage, even if the Licensor has been advised of the possibility of such damage. However,
115
+ the Licensor will be liable under statutory product liability laws as far such laws apply to the Work.
116
+
117
+ 9.Additional agreements
118
+ While distributing the Work, You may choose to conclude an additional agreement, defining obligations or services
119
+ consistent with this Licence. However, if accepting obligations, You may act only on your own behalf and on your sole
120
+ responsibility, not on behalf of the original Licensor or any other Contributor, and only if You agree to indemnify,
121
+ defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against such Contributor by
122
+ the fact You have accepted any warranty or additional liability.
123
+
124
+ 10.Acceptance of the Licence
125
+ The provisions of this Licence can be accepted by clicking on an icon ‘I agree’ placed under the bottom of a window
126
+ displaying the text of this Licence or by affirming consent in any other similar way, in accordance with the rules of
127
+ applicable law. Clicking on that icon indicates your clear and irrevocable acceptance of this Licence and all of its terms
128
+ and conditions.
129
+ Similarly, you irrevocably accept this Licence and all of its terms and conditions by exercising any rights granted to You
130
+ by Article 2 of this Licence, such as the use of the Work, the creation by You of a Derivative Work or the Distribution
131
+ or Communication by You of the Work or copies thereof.
132
+
133
+ 11.Information to the public
134
+ In case of any Distribution or Communication of the Work by means of electronic communication by You (for example,
135
+ by offering to download the Work from a remote location) the distribution channel or media (for example, a website)
136
+ must at least provide to the public the information requested by the applicable law regarding the Licensor, the Licence
137
+ and the way it may be accessible, concluded, stored and reproduced by the Licensee.
138
+
139
+ 12.Termination of the Licence
140
+ The Licence and the rights granted hereunder will terminate automatically upon any breach by the Licensee of the terms
141
+ of the Licence.
142
+ Such a termination will not terminate the licences of any person who has received the Work from the Licensee under
143
+ the Licence, provided such persons remain in full compliance with the Licence.
144
+
145
+ 13.Miscellaneous
146
+ Without prejudice of Article 9 above, the Licence represents the complete agreement between the Parties as to the
147
+ Work.
148
+ If any provision of the Licence is invalid or unenforceable under applicable law, this will not affect the validity or
149
+ enforceability of the Licence as a whole. Such provision will be construed or reformed so as necessary to make it valid
150
+ and enforceable.
151
+ The European Commission may publish other linguistic versions or new versions of this Licence or updated versions of
152
+ the Appendix, so far this is required and reasonable, without reducing the scope of the rights granted by the Licence.
153
+ New versions of the Licence will be published with a unique version number.
154
+ All linguistic versions of this Licence, approved by the European Commission, have identical value. Parties can take
155
+ advantage of the linguistic version of their choice.
156
+
157
+ 14.Jurisdiction
158
+ Without prejudice to specific agreement between parties,
159
+ — any litigation resulting from the interpretation of this License, arising between the European Union institutions,
160
+ bodies, offices or agencies, as a Licensor, and any Licensee, will be subject to the jurisdiction of the Court of Justice
161
+ of the European Union, as laid down in article 272 of the Treaty on the Functioning of the European Union,
162
+ — any litigation arising between other parties and resulting from the interpretation of this License, will be subject to
163
+ the exclusive jurisdiction of the competent court where the Licensor resides or conducts its primary business.
164
+
165
+ 15.Applicable Law
166
+ Without prejudice to specific agreement between parties,
167
+ — this Licence shall be governed by the law of the European Union Member State where the Licensor has his seat,
168
+ resides or has his registered office,
169
+ — this licence shall be governed by Belgian law if the Licensor has no seat, residence or registered office inside
170
+ a European Union Member State.
171
+
172
+
173
+ Appendix
174
+
175
+ ‘Compatible Licences’ according to Article 5 EUPL are:
176
+ — GNU General Public License (GPL) v. 2, v. 3
177
+ — GNU Affero General Public License (AGPL) v. 3
178
+ — Open Software License (OSL) v. 2.1, v. 3.0
179
+ — Eclipse Public License (EPL) v. 1.0
180
+ — CeCILL v. 2.0, v. 2.1
181
+ — Mozilla Public Licence (MPL) v. 2
182
+ — GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
183
+ — Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for works other than software
184
+ — European Union Public Licence (EUPL) v. 1.1, v. 1.2
185
+ — Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong Reciprocity (LiLiQ-R+).
186
+
187
+ The European Commission may update this Appendix to later versions of the above licences without producing
188
+ a new version of the EUPL, as long as they provide the rights granted in Article 2 of this Licence and protect the
189
+ covered Source Code from exclusive appropriation.
190
+ All other changes or additions to this Appendix require the production of a new EUPL version.
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.4
2
+ Name: scholaris-sdk
3
+ Version: 2.0.0
4
+ Summary: Cliente de Python para Scholaris: API de citas con página verificada y lector de SPDF 4.0 sin conexión
5
+ Author-email: José Luis Saorín Ferrer <jl@joseluissaorin.com>
6
+ License-Expression: EUPL-1.2
7
+ Project-URL: Homepage, https://scholaris.joseluissaorin.com
8
+ Project-URL: Documentation, https://scholaris.joseluissaorin.com/api
9
+ Project-URL: Source, https://github.com/joseluissaorin/scholaris-v2
10
+ Project-URL: Issues, https://github.com/joseluissaorin/scholaris-v2/issues
11
+ Keywords: scholaris,citas,citations,spdf,bibliografía,rag,academic
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Natural Language :: Spanish
16
+ Classifier: Natural Language :: English
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
19
+ Classifier: Topic :: Text Processing :: Markup
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3 :: Only
22
+ Classifier: Programming Language :: Python :: 3.9
23
+ Classifier: Programming Language :: Python :: 3.10
24
+ Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
26
+ Classifier: Programming Language :: Python :: 3.13
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: requests>=2.31.0
31
+ Provides-Extra: vectores
32
+ Requires-Dist: numpy>=1.24.0; extra == "vectores"
33
+ Provides-Extra: v1
34
+ Requires-Dist: python-dotenv>=1.0.0; extra == "v1"
35
+ Requires-Dist: pdf2bib>=1.2; extra == "v1"
36
+ Requires-Dist: bibtexparser>=1.4.0; extra == "v1"
37
+ Requires-Dist: PyPaperBot>=1.2.0; extra == "v1"
38
+ Requires-Dist: google-generativeai>=0.3.0; extra == "v1"
39
+ Requires-Dist: google-api-python-client>=2.0.0; extra == "v1"
40
+ Requires-Dist: python-docx>=0.8.11; extra == "v1"
41
+ Requires-Dist: markdown>=3.4.0; extra == "v1"
42
+ Requires-Dist: beautifulsoup4>=4.11.0; extra == "v1"
43
+ Requires-Dist: PyMuPDF>=1.23.0; extra == "v1"
44
+ Requires-Dist: numpy>=1.24.0; extra == "v1"
45
+ Requires-Dist: Pillow>=9.0.0; extra == "v1"
46
+ Provides-Extra: dev
47
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
48
+ Requires-Dist: numpy>=1.24.0; extra == "dev"
49
+ Dynamic: license-file
50
+
51
+ # scholaris-sdk
52
+
53
+ Cliente de Python para [Scholaris](https://scholaris.joseluissaorin.com), la
54
+ biblioteca académica que lee tus fuentes (PDF, EPUB, webs, vídeos, pódcast) y
55
+ cita con el número de página impreso, verificado contra el texto. Incluye
56
+ además un lector de SPDF 4.0 que funciona sin conexión.
57
+
58
+ *Python client for Scholaris: upload sources, search them, ask questions and
59
+ get citations with verified printed page numbers; plus an offline reader for
60
+ SPDF 4.0 files. The API speaks Spanish identifiers; errors carry both a Spanish
61
+ `mensaje` and an English `message`.*
62
+
63
+ ```bash
64
+ pip install scholaris-sdk # solo depende de requests
65
+ pip install "scholaris-sdk[vectores]" # numpy, para la búsqueda vectorial sin conexión
66
+ ```
67
+
68
+ El paquete se importa como `scholaris`. Requiere Python 3.9 o posterior.
69
+
70
+ ## Primeros pasos con la instancia pública
71
+
72
+ Crea una clave en Scholaris (Ajustes → Claves de API) y guárdala en la
73
+ variable `SCHOLARIS_CLAVE` o pásala directamente:
74
+
75
+ ```python
76
+ from scholaris.api import Scholaris
77
+
78
+ s = Scholaris("sch_…") # o la variable SCHOLARIS_CLAVE
79
+ doc = s.subir("articulo.pdf") # también una URL: web, PDF, YouTube, pódcast
80
+ for p in s.buscar("atención escalada", k=3):
81
+ print(p["cita"], p["texto"][:80]) # «(Vaswani et al., 2017, p. 4)»
82
+ print(s.preguntar("¿Qué es la atención multicabeza?")["respuesta"]) # Markdown con notas [^n]
83
+ print(s.citar("La atención sustituye a la recurrencia.")["texto"])
84
+ print(s.verificar("El Transformer prescinde de la recurrencia.")["veredicto"])
85
+ print(s.texto(doc["id"], desde="23", hasta="25", markdown=True)) # páginas por su folio impreso
86
+ ```
87
+
88
+ `scholaris.api` es la API pública v1 (`/api/v1`), pensada para lo más común.
89
+ La guía completa está en <https://scholaris.joseluissaorin.com/api>. Los errores
90
+ son `ErrorScholaris`, con `codigo`, `mensaje` (español) y `message` (inglés).
91
+
92
+ ## Contra un servidor local
93
+
94
+ Scholaris también funciona en tu ordenador con SQLite y el disco. Desde el
95
+ repositorio:
96
+
97
+ ```bash
98
+ pnpm install
99
+ pnpm --filter @scholaris/local start # escucha en http://localhost:8790
100
+ ```
101
+
102
+ ```python
103
+ from scholaris.api import Scholaris
104
+
105
+ s = Scholaris(base="http://localhost:8790") # sin clave si no defines SCHOLARIS_TOKEN
106
+ ```
107
+
108
+ Si arrancas el servidor con `SCHOLARIS_TOKEN=…`, pasa ese mismo valor como
109
+ clave. La URL por defecto también se puede fijar con la variable `SCHOLARIS_URL`.
110
+
111
+ ## La API completa (v2)
112
+
113
+ Bibliotecas compartidas, metadatos, autocitas de documentos enteros, paquetes
114
+ `.scholaris` y descarga de SPDF:
115
+
116
+ ```python
117
+ from scholaris.v2 import Scholaris
118
+
119
+ s = Scholaris("https://scholaris.joseluissaorin.com", clave="sch_…")
120
+ doc = s.subir("articulo.pdf") # sube, convierte y espera a que esté listo
121
+ s.subir_url("https://www.youtube.com/watch?v=…")
122
+ for r in s.buscar("atención escalada", k=5):
123
+ print(r["citaCorta"], r["fragmento"]["texto"][:80])
124
+ print(s.respuesta("¿Qué es la atención multicabeza?")["texto"])
125
+ s.descargar_spdf(doc["id"], "articulo.spdf")
126
+ autocita = s.autocitar("mi-trabajo.docx", estilo="apa")
127
+ s.exportar_autocita(autocita["id"], "mi-trabajo-citado.docx")
128
+ ```
129
+
130
+ Los errores son `ErrorApi`, con `estado`, `codigo` y `mensaje`.
131
+
132
+ ## SPDF 4.0 sin conexión
133
+
134
+ Un SPDF es el documento ya procesado (texto por páginas con su folio impreso,
135
+ fragmentos, metadatos y, si se quiere, el original) en un único fichero
136
+ SQLite. Se lee sin red ni clave:
137
+
138
+ ```python
139
+ from scholaris.v2 import SPDF
140
+
141
+ with SPDF.abrir("vigilar.spdf") as s:
142
+ print(s.documento["metadatos"]["titulo"])
143
+ for f in s.buscar("panóptico", k=5): # FTS5, insensible a acentos
144
+ print(f.cita, f.texto[:80]) # «(Foucault, 1975, p. 23) …»
145
+ print(s.pagina("145").texto) # por número de página impreso
146
+ ```
147
+
148
+ ## La v1 local
149
+
150
+ La primera versión de Scholaris (procesado local con PyMuPDF y Gemini,
151
+ `CitationIndex`, SPDF 1.0 a 3.0 y la orden `scholaris`) sigue dentro del
152
+ paquete como extra opcional:
153
+
154
+ ```bash
155
+ pip install "scholaris-sdk[v1]"
156
+ ```
157
+
158
+ Su documentación está en <https://github.com/joseluissaorin/scholaris>.
159
+
160
+ ## Nota sobre el nombre
161
+
162
+ En PyPI ya existe un proyecto distinto llamado `scholaris`, que también se
163
+ importa como `scholaris`. No instales los dos en el mismo entorno.
164
+
165
+ ## Licencia
166
+
167
+ [EUPL-1.2](https://interoperable-europe.ec.europa.eu/collection/eupl/eupl-text-eupl-12).
168
+ Código fuente: <https://github.com/joseluissaorin/scholaris-v2>.
@@ -0,0 +1,118 @@
1
+ # scholaris-sdk
2
+
3
+ Cliente de Python para [Scholaris](https://scholaris.joseluissaorin.com), la
4
+ biblioteca académica que lee tus fuentes (PDF, EPUB, webs, vídeos, pódcast) y
5
+ cita con el número de página impreso, verificado contra el texto. Incluye
6
+ además un lector de SPDF 4.0 que funciona sin conexión.
7
+
8
+ *Python client for Scholaris: upload sources, search them, ask questions and
9
+ get citations with verified printed page numbers; plus an offline reader for
10
+ SPDF 4.0 files. The API speaks Spanish identifiers; errors carry both a Spanish
11
+ `mensaje` and an English `message`.*
12
+
13
+ ```bash
14
+ pip install scholaris-sdk # solo depende de requests
15
+ pip install "scholaris-sdk[vectores]" # numpy, para la búsqueda vectorial sin conexión
16
+ ```
17
+
18
+ El paquete se importa como `scholaris`. Requiere Python 3.9 o posterior.
19
+
20
+ ## Primeros pasos con la instancia pública
21
+
22
+ Crea una clave en Scholaris (Ajustes → Claves de API) y guárdala en la
23
+ variable `SCHOLARIS_CLAVE` o pásala directamente:
24
+
25
+ ```python
26
+ from scholaris.api import Scholaris
27
+
28
+ s = Scholaris("sch_…") # o la variable SCHOLARIS_CLAVE
29
+ doc = s.subir("articulo.pdf") # también una URL: web, PDF, YouTube, pódcast
30
+ for p in s.buscar("atención escalada", k=3):
31
+ print(p["cita"], p["texto"][:80]) # «(Vaswani et al., 2017, p. 4)»
32
+ print(s.preguntar("¿Qué es la atención multicabeza?")["respuesta"]) # Markdown con notas [^n]
33
+ print(s.citar("La atención sustituye a la recurrencia.")["texto"])
34
+ print(s.verificar("El Transformer prescinde de la recurrencia.")["veredicto"])
35
+ print(s.texto(doc["id"], desde="23", hasta="25", markdown=True)) # páginas por su folio impreso
36
+ ```
37
+
38
+ `scholaris.api` es la API pública v1 (`/api/v1`), pensada para lo más común.
39
+ La guía completa está en <https://scholaris.joseluissaorin.com/api>. Los errores
40
+ son `ErrorScholaris`, con `codigo`, `mensaje` (español) y `message` (inglés).
41
+
42
+ ## Contra un servidor local
43
+
44
+ Scholaris también funciona en tu ordenador con SQLite y el disco. Desde el
45
+ repositorio:
46
+
47
+ ```bash
48
+ pnpm install
49
+ pnpm --filter @scholaris/local start # escucha en http://localhost:8790
50
+ ```
51
+
52
+ ```python
53
+ from scholaris.api import Scholaris
54
+
55
+ s = Scholaris(base="http://localhost:8790") # sin clave si no defines SCHOLARIS_TOKEN
56
+ ```
57
+
58
+ Si arrancas el servidor con `SCHOLARIS_TOKEN=…`, pasa ese mismo valor como
59
+ clave. La URL por defecto también se puede fijar con la variable `SCHOLARIS_URL`.
60
+
61
+ ## La API completa (v2)
62
+
63
+ Bibliotecas compartidas, metadatos, autocitas de documentos enteros, paquetes
64
+ `.scholaris` y descarga de SPDF:
65
+
66
+ ```python
67
+ from scholaris.v2 import Scholaris
68
+
69
+ s = Scholaris("https://scholaris.joseluissaorin.com", clave="sch_…")
70
+ doc = s.subir("articulo.pdf") # sube, convierte y espera a que esté listo
71
+ s.subir_url("https://www.youtube.com/watch?v=…")
72
+ for r in s.buscar("atención escalada", k=5):
73
+ print(r["citaCorta"], r["fragmento"]["texto"][:80])
74
+ print(s.respuesta("¿Qué es la atención multicabeza?")["texto"])
75
+ s.descargar_spdf(doc["id"], "articulo.spdf")
76
+ autocita = s.autocitar("mi-trabajo.docx", estilo="apa")
77
+ s.exportar_autocita(autocita["id"], "mi-trabajo-citado.docx")
78
+ ```
79
+
80
+ Los errores son `ErrorApi`, con `estado`, `codigo` y `mensaje`.
81
+
82
+ ## SPDF 4.0 sin conexión
83
+
84
+ Un SPDF es el documento ya procesado (texto por páginas con su folio impreso,
85
+ fragmentos, metadatos y, si se quiere, el original) en un único fichero
86
+ SQLite. Se lee sin red ni clave:
87
+
88
+ ```python
89
+ from scholaris.v2 import SPDF
90
+
91
+ with SPDF.abrir("vigilar.spdf") as s:
92
+ print(s.documento["metadatos"]["titulo"])
93
+ for f in s.buscar("panóptico", k=5): # FTS5, insensible a acentos
94
+ print(f.cita, f.texto[:80]) # «(Foucault, 1975, p. 23) …»
95
+ print(s.pagina("145").texto) # por número de página impreso
96
+ ```
97
+
98
+ ## La v1 local
99
+
100
+ La primera versión de Scholaris (procesado local con PyMuPDF y Gemini,
101
+ `CitationIndex`, SPDF 1.0 a 3.0 y la orden `scholaris`) sigue dentro del
102
+ paquete como extra opcional:
103
+
104
+ ```bash
105
+ pip install "scholaris-sdk[v1]"
106
+ ```
107
+
108
+ Su documentación está en <https://github.com/joseluissaorin/scholaris>.
109
+
110
+ ## Nota sobre el nombre
111
+
112
+ En PyPI ya existe un proyecto distinto llamado `scholaris`, que también se
113
+ importa como `scholaris`. No instales los dos en el mismo entorno.
114
+
115
+ ## Licencia
116
+
117
+ [EUPL-1.2](https://interoperable-europe.ec.europa.eu/collection/eupl/eupl-text-eupl-12).
118
+ Código fuente: <https://github.com/joseluissaorin/scholaris-v2>.
@@ -0,0 +1,81 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "scholaris-sdk"
7
+ version = "2.0.0"
8
+ authors = [
9
+ {name = "José Luis Saorín Ferrer", email = "jl@joseluissaorin.com"},
10
+ ]
11
+ description = "Cliente de Python para Scholaris: API de citas con página verificada y lector de SPDF 4.0 sin conexión"
12
+ readme = "README.md"
13
+ license = "EUPL-1.2"
14
+ license-files = ["LICENSE"]
15
+ requires-python = ">=3.9"
16
+ keywords = ["scholaris", "citas", "citations", "spdf", "bibliografía", "rag", "academic"]
17
+ classifiers = [
18
+ "Development Status :: 4 - Beta",
19
+ "Intended Audience :: Science/Research",
20
+ "Intended Audience :: Developers",
21
+ "Natural Language :: Spanish",
22
+ "Natural Language :: English",
23
+ "Operating System :: OS Independent",
24
+ "Topic :: Scientific/Engineering :: Information Analysis",
25
+ "Topic :: Text Processing :: Markup",
26
+ "Programming Language :: Python :: 3",
27
+ "Programming Language :: Python :: 3 :: Only",
28
+ "Programming Language :: Python :: 3.9",
29
+ "Programming Language :: Python :: 3.10",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Programming Language :: Python :: 3.12",
32
+ "Programming Language :: Python :: 3.13",
33
+ ]
34
+ dependencies = [
35
+ "requests>=2.31.0",
36
+ ]
37
+
38
+ [project.optional-dependencies]
39
+ vectores = ["numpy>=1.24.0"]
40
+ v1 = [
41
+ "python-dotenv>=1.0.0",
42
+ "pdf2bib>=1.2",
43
+ "bibtexparser>=1.4.0",
44
+ "PyPaperBot>=1.2.0",
45
+ "google-generativeai>=0.3.0",
46
+ "google-api-python-client>=2.0.0",
47
+ "python-docx>=0.8.11",
48
+ "markdown>=3.4.0",
49
+ "beautifulsoup4>=4.11.0",
50
+ "PyMuPDF>=1.23.0",
51
+ "numpy>=1.24.0",
52
+ "Pillow>=9.0.0",
53
+ ]
54
+ dev = [
55
+ "pytest>=7.0.0",
56
+ "numpy>=1.24.0",
57
+ ]
58
+
59
+ [project.scripts]
60
+ scholaris = "scholaris.cli:main"
61
+
62
+ [project.urls]
63
+ Homepage = "https://scholaris.joseluissaorin.com"
64
+ Documentation = "https://scholaris.joseluissaorin.com/api"
65
+ Source = "https://github.com/joseluissaorin/scholaris-v2"
66
+ Issues = "https://github.com/joseluissaorin/scholaris-v2/issues"
67
+
68
+ # Solo se publica el paquete `scholaris`. `spdf/` (referencia de los formatos
69
+ # SPDF 1.0 a 3.0) se queda en el repositorio: su nombre ya existe en PyPI.
70
+ [tool.setuptools.packages.find]
71
+ include = ["scholaris", "scholaris.*"]
72
+
73
+ [tool.black]
74
+ line-length = 100
75
+ target-version = ['py39', 'py310', 'py311', 'py312']
76
+
77
+ [tool.mypy]
78
+ python_version = "3.9"
79
+ warn_return_any = true
80
+ warn_unused_configs = true
81
+ disallow_untyped_defs = false
@@ -0,0 +1,48 @@
1
+ """Scholaris - Academic Research Automation Library.
2
+
3
+ A Python library for academic research automation including:
4
+ - Bibliography search and download
5
+ - BibTeX generation
6
+ - Literature review generation
7
+ - Academic writing assistance
8
+ """
9
+
10
+ import importlib
11
+ from typing import Any
12
+
13
+ # La v1 (procesado local con PyMuPDF y Gemini) se carga solo si se usa: así
14
+ # `scholaris.v2` (lector de SPDF 4.0 y cliente de la API) no necesita sus dependencias.
15
+ _PEREZOSOS = {
16
+ "Config": ".config",
17
+ "ScholarisError": ".exceptions", "ConfigurationError": ".exceptions", "SearchError": ".exceptions",
18
+ "DownloadError": ".exceptions", "BibTeXError": ".exceptions", "LLMError": ".exceptions",
19
+ "RateLimitError": ".exceptions", "ConversionError": ".exceptions", "ValidationError": ".exceptions",
20
+ "Paper": ".core.models", "Reference": ".core.models", "Section": ".core.models", "Review": ".core.models",
21
+ "Scholaris": ".scholaris",
22
+ }
23
+
24
+
25
+ def __getattr__(nombre: str) -> Any:
26
+ if nombre in _PEREZOSOS:
27
+ return getattr(importlib.import_module(_PEREZOSOS[nombre], __name__), nombre)
28
+ raise AttributeError(nombre)
29
+
30
+
31
+ __version__ = "2.0.0"
32
+ __all__ = [
33
+ "Scholaris",
34
+ "Config",
35
+ "Paper",
36
+ "Reference",
37
+ "Section",
38
+ "Review",
39
+ "ScholarisError",
40
+ "ConfigurationError",
41
+ "SearchError",
42
+ "DownloadError",
43
+ "BibTeXError",
44
+ "LLMError",
45
+ "RateLimitError",
46
+ "ConversionError",
47
+ "ValidationError",
48
+ ]