bp_text.textfragment
This module implements the TextFragment class.
A text fragment is an item that contains (in the data slot) a token or any other
text data, combined with any other relevant data. This is esp. a key, which
is most often a BibTeX citekey, and some other meta-data, most likely retreived
from the meta slot of a Pool instance.
Created: 2025-05-06 Author: Ruben Philipp <me@rubenphilipp.com>
$$ Last modified: 16:49:30 Wed May 7 2025 CEST
Functions
|
This function takes a list of |
Classes
|
This class implements a TextFragment. |
- class bp_text.textfragment.TextFragment(key, page_label=None, meta={}, data=None)[source]
Bases:
objectThis class implements a TextFragment.
A text fragment is an item that contains (in the data slot) a token or any other text data, combined with any other relevant data. This is esp. a key, which is most often a BibTeX citekey, and some other meta-data, most likely retreived from the meta slot of a
Poolinstance.- Parameters:
key (string) – A (unique) key. This is most likely a BibTeX citekey.
meta (dict) – A dict holding metadata, most likely derived from a BibTeX entry.
data (any) – Any (text) data associated with this item. This is most likely a spacy.doc or spacy.token object.
- property data
Getter/setter for the data.
- format_org(cite=True, force_cite=False)[source]
This returns a formatted string with the text contained in data in org-mode syntax.
- Parameters:
cite (boolean) – When True, an org-cite citation will be appended to the generated string. Default = True
force_cite (boolean) – When True (and cite = True), also for a citation for text elements that normally don’t “require” a citation (e.g. PUNCT). Default = False
- Returns:
A string with the content of text formatted in org-mode syntax.
- property key
Getter/setter for the key.
- property meta
Getter/setter for the meta dict.
- property page_label
Getter/setter for the page_label.
- bp_text.textfragment.textfragments_to_org(fragment_list, cite=True, force_cite=False)[source]
This function takes a list of
TextFragmentobjects and returns a string formatted in org-mode syntax, (optionally) including org-cite references.- Parameters:
fragment_list (A list with
TextFragmentobjects.) – TheTextFragmentobjects.cite (boolean) – When True, an org-cite citation will be appended to the generated string. Default = True
force_cite (boolean) – When True (and cite = True), also for a citation for text elements that normally don’t “require” a citation (e.g. PUNC). Default = False