Fabula-fr
fabula-fr est une bibliothèque Python pour analyser l’évolution du sentiment et/ou des émotions dans un texte et produire des arcs narratifs lissés.
Le package fournit :
- une API Python (
Fabula), - une CLI (
fabula score/fabula arc), - des utilitaires de segmentation,
- des fonctions de resampling + lissage,
- des helpers de visualisation.
Installation
pip install fabula-fr
Pour le développement local :
pip install -e .[dev]
Démarrage rapide
API Python
from fabula.core import Fabula
from fabula.scorer import TransformersScorer
scorer = TransformersScorer(model="cmarkea/distilcamembert-base-sentiment")
fb = Fabula(scorer=scorer, analysis="sentiment")
text = "Bonjour. C'est une belle journée. Je suis triste."
# Scores par segment
scores = fb.score(text)
print(scores[["idx", "rel_pos", "label", "score"]])
# Arc narratif lissé
arc = fb.arc(text, n_points=100, smooth_window=7)
print(len(arc.x), len(arc.y))
CLI
# Scoring par segments (JSON)
fabula score mon_texte.txt --format json
# Scoring par segments (CSV)
fabula score mon_texte.txt --format csv
# Arc narratif
fabula arc mon_texte.txt --n-points 120 --smooth-window 9 --format csv
Lecture depuis stdin :
cat mon_texte.txt | fabula score - --format json
Segmentation
Segmenters disponibles
RegexSentenceSegmenter: segmentation par ponctuation terminale.ParagraphSegmenter: segmentation par paragraphes (\n\n).SlidingWindowTokenSegmenter: fenêtres glissantes sur tokens.DocumentChunkTokenSegmenter: chunks de document par tokens.
Choix via CLI
Actuellement la CLI expose :
--segment sentence--segment paragraph
Scoring et modèles
Mode standard
Par défaut, la CLI utilise TransformersScorer avec le modèle :
cmarkea/distilcamembert-base-sentiment
Vous pouvez le changer :
fabula score mon_texte.txt --model astrosbd/french_emotion_camembert
Mode sans téléchargement (--dummy)
Pour des tests rapides sans dépendre de Hugging Face :
fabula score mon_texte.txt --dummy
fabula arc mon_texte.txt --dummy
Arcs narratifs
Fabula.arc(...) :
- récupère les scores segmentés,
- interpole vers
n_points(resample_to_n), - applique un lissage (
smooth_series).
Vous pouvez aussi générer des arcs multi-séries avec score_col="probs" dans l’API Python.
Visualisation
Le module fabula.plot expose :
plot_arc(...)pour un arc scalaire,plot_arc_series(...)pour plusieurs séries.
Exemple :
from fabula.plot import plot_arc
fig, ax = plot_arc(arc, title="Arc narratif", save_path="arc.png")
Tests
Exécuter les tests :
python -m pytest -q
Citation
Si vous utilisez fabula, merci de citer :
Cafiero, Florian, et Alexandre Lionnet. Des émotions au fil du récit : fabula, un package pour analyser les textes francophones par Transformers. Communication présentée à Humanistica 2026 (Paris), à paraître dans Anthology of Computers and the Humanities.
Metadata
Release files for fabula-fr 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fabula_fr-0.1.4.tar.gz | 9.7 kB | With provenance | Details for fabula_fr-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fabula_fr-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for fabula_fr-0.1.4-py3-none-any.whl |
Total release size: 20.5 kB
Release files / fabula_fr-0.1.4.tar.gz
| Download URL | fabula_fr-0.1.4.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a9b8b25830ffae866952fd2860f37fd38be4dc650e7c861b2b8bd295162d45b
|
|
BLAKE2b-256 checksum How to use checksums |
a02a3422eed98f0d417c435c5f4c9ed6f81badc801bc5a5c85e917836ec40ae1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 7, 2026.
Transparency logRelease files / fabula_fr-0.1.4-py3-none-any.whl
| Download URL | fabula_fr-0.1.4-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5184127eff38b627d9b9bb08c651e2f13904ad185a11bb5ac333dcb7a982489c
|
|
BLAKE2b-256 checksum How to use checksums |
745aa16d7a91093afe7d4b2d8ce57f3e524edc5b0f5168399080b8a921384753
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 7, 2026.
Transparency logSecurity for fabula-fr 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for fabula_fr-0.1.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 7, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.