Transformers-based narrative sentiment/emotion arcs for literature (syuzhet-like).
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fabula_fr-0.1.3.tar.gz.
File metadata
- Download URL: fabula_fr-0.1.3.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5aa7fb7e367f47e0f5b7517a50fc8c3b3c045e1ae49c816dec9e36cdb8583c9f
|
|
| MD5 |
86f8827c37cff0dbc7906dcd03b21659
|
|
| BLAKE2b-256 |
2e0565145ae630e3962361480eddbc5e2da5b64a91667f6c810e3f443fe4cfbd
|
Provenance
The following attestation bundles were made for fabula_fr-0.1.3.tar.gz:
Publisher:
python-publish.yml on floriancafiero/fabula-fr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fabula_fr-0.1.3.tar.gz -
Subject digest:
5aa7fb7e367f47e0f5b7517a50fc8c3b3c045e1ae49c816dec9e36cdb8583c9f - Sigstore transparency entry: 1247010867
- Sigstore integration time:
-
Permalink:
floriancafiero/fabula-fr@d253eac8e18ec0bca1f883a9e0fe868b3b747c53 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/floriancafiero
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d253eac8e18ec0bca1f883a9e0fe868b3b747c53 -
Trigger Event:
release
-
Statement type:
File details
Details for the file fabula_fr-0.1.3-py3-none-any.whl.
File metadata
- Download URL: fabula_fr-0.1.3-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a4408e7fd05c4c90b7a4317d9640f7cb8d6b2cfe52d59f3debe77a1e103ca2c
|
|
| MD5 |
b0e92719682a7c797e94c094f1d843b2
|
|
| BLAKE2b-256 |
55871f62605d86b981250701f1fdade7b244136b2ac5f2dd65ae9d5d83080821
|
Provenance
The following attestation bundles were made for fabula_fr-0.1.3-py3-none-any.whl:
Publisher:
python-publish.yml on floriancafiero/fabula-fr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fabula_fr-0.1.3-py3-none-any.whl -
Subject digest:
5a4408e7fd05c4c90b7a4317d9640f7cb8d6b2cfe52d59f3debe77a1e103ca2c - Sigstore transparency entry: 1247010982
- Sigstore integration time:
-
Permalink:
floriancafiero/fabula-fr@d253eac8e18ec0bca1f883a9e0fe868b3b747c53 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/floriancafiero
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d253eac8e18ec0bca1f883a9e0fe868b3b747c53 -
Trigger Event:
release
-
Statement type: