Python LMF library
 All Classes Namespaces Files Functions Variables
Functions
pylmflib.pylmflib.output.tex Namespace Reference

Functions

def file_read
 Read file contents. More...
 
def insert_references
 Insert references to paradigms. More...
 
def tex_write
 Write a LaTeX file. More...
 
def handle_font
 Functions to process LaTeX layout. More...
 
def handle_reserved
 
def handle_fi
 
def handle_fv
 
def handle_fn
 
def handle_pinyin
 
def handle_caps
 
def handle_quotes
 
def format_uid
 Functions to process LaTeX fields (output) More...
 
def format_link
 Display hyperlink to a lexical entry in LaTeX format. More...
 
def format_lexeme
 'lx', 'hm' and 'lc' fields are flipped if 'lc' field has data. More...
 
def format_audio
 Embed sound file into PDF. More...
 
def format_part_of_speech
 Display part of speech in LaTeX format. More...
 
def format_definitions
 Glosses are supplanted by definitions. More...
 
def format_lt
 Display 'lt' in LaTeX format. More...
 
def format_sc
 Display 'sc' in LaTeX format. More...
 
def format_rf
 Display 'rf' in LaTeX format. More...
 
def format_examples
 Display examples in LaTeX format. More...
 
def format_usage_notes
 Display usage notes in LaTeX format. More...
 
def format_encyclopedic_informations
 Display encyclopedic informations in LaTeX format. More...
 
def format_restrictions
 Display restrictions in LaTeX format. More...
 
def format_lexical_functions
 Display lexical functions in LaTeX format. More...
 
def format_related_forms
 Display related forms in LaTeX format. More...
 
def format_variant_forms
 Display variant forms in LaTeX format. More...
 
def format_borrowed_word
 Display borrowed word in LaTeX format. More...
 
def format_etymology
 Display etymology in LaTeX format. More...
 
def format_paradigms
 Display all paradigms in LaTeX format. More...
 
def format_table
 Display a table in LaTeX format. More...
 
def format_semantic_domains
 Display semantic domains in LaTeX format. More...
 
def format_bibliography
 Display bibliography in LaTeX format. More...
 
def format_picture
 Display a picture in LaTeX format. More...
 
def format_notes
 Display all notes in LaTeX format. More...
 
def format_source
 Display source in LaTeX format. More...
 
def format_status
 Display status in LaTeX format. More...
 
def format_date
 Do not display date in LaTeX format. More...
 

Function Documentation

def pylmflib.pylmflib.output.tex.file_read (   filename)

Read file contents.

Parameters
filenameThe name of the file with full path containing information to read, for instance the LaTeX header of the document: 'user/config/header.tex'.
Returns
A Python string containing read information.

Definition at line 16 of file tex.py.

def pylmflib.pylmflib.output.tex.format_audio (   lexical_entry,
  font 
)

Embed sound file into PDF.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string embedding sound in LaTeX format.

Definition at line 358 of file tex.py.

def pylmflib.pylmflib.output.tex.format_bibliography (   lexical_entry,
  font 
)

Display bibliography in LaTeX format.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing bibliography in LaTeX format.

Definition at line 740 of file tex.py.

def pylmflib.pylmflib.output.tex.format_borrowed_word (   lexical_entry,
  font 
)

Display borrowed word in LaTeX format.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing borrowed word in LaTeX format.

Definition at line 646 of file tex.py.

def pylmflib.pylmflib.output.tex.format_date (   lexical_entry,
  font 
)

Do not display date in LaTeX format.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
An empty string.

Definition at line 803 of file tex.py.

def pylmflib.pylmflib.output.tex.format_definitions (   sense,
  font,
  languages = None 
)

Glosses are supplanted by definitions.

Parameters
senseThe current Sense LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
languagesA list of languages to consider for definitions and glosses (all by default).
Returns
A string representing glosses and definitions in LaTeX format.

Definition at line 433 of file tex.py.

def pylmflib.pylmflib.output.tex.format_encyclopedic_informations (   sense,
  font 
)

Display encyclopedic informations in LaTeX format.

Parameters
senseThe current Sense LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing encyclopedic informations in LaTeX format.

Definition at line 545 of file tex.py.

def pylmflib.pylmflib.output.tex.format_etymology (   lexical_entry,
  font 
)

Display etymology in LaTeX format.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing etymology in LaTeX format.

Definition at line 660 of file tex.py.

def pylmflib.pylmflib.output.tex.format_examples (   sense,
  font,
  languages = None 
)

Display examples in LaTeX format.

Parameters
senseThe current Sense LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
languagesA list of languages to consider for examples (all by default).
Returns
A string representing examples in LaTeX format.

Definition at line 501 of file tex.py.

def pylmflib.pylmflib.output.tex.format_lexeme (   lexical_entry,
  font 
)

'lx', 'hm' and 'lc' fields are flipped if 'lc' field has data.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing lexeme in LaTeX format.

Definition at line 330 of file tex.py.

def pylmflib.pylmflib.output.tex.format_lexical_functions (   lexical_entry,
  font 
)

Display lexical functions in LaTeX format.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing lexical functions in LaTeX format.

Definition at line 579 of file tex.py.

def pylmflib.pylmflib.output.tex.format_link (   lexical_entry,
  font 
)

Display hyperlink to a lexical entry in LaTeX format.

Parameters
lexical_entryThe targeted Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing the hyperlink in LaTeX format.

Definition at line 318 of file tex.py.

def pylmflib.pylmflib.output.tex.format_lt (   sense,
  font 
)

Display 'lt' in LaTeX format.

Parameters
senseThe current Sense LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing 'lt' in LaTeX format.

Definition at line 474 of file tex.py.

def pylmflib.pylmflib.output.tex.format_notes (   lexical_entry,
  font 
)

Display all notes in LaTeX format.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing all notes in LaTeX format.

Definition at line 760 of file tex.py.

def pylmflib.pylmflib.output.tex.format_paradigms (   lexical_entry,
  font 
)

Display all paradigms in LaTeX format.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing all paradigms in LaTeX format.

Definition at line 673 of file tex.py.

def pylmflib.pylmflib.output.tex.format_part_of_speech (   lexical_entry,
  font,
  mapping = partOfSpeech_tex,
  language = None 
)

Display part of speech in LaTeX format.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
mappingA Python dictionary giving the mapping between LMF part of speech LexicalEntry attribute value and LaTeX layout.
languageLanguage to consider to display part of speech.
Returns
A string representing part of speech in LaTeX format.

Definition at line 414 of file tex.py.

def pylmflib.pylmflib.output.tex.format_picture (   lexical_entry,
  font 
)

Display a picture in LaTeX format.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing a picture in LaTeX format.

Definition at line 751 of file tex.py.

def pylmflib.pylmflib.output.tex.format_related_forms (   lexical_entry,
  font 
)

Display related forms in LaTeX format.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing related forms in LaTeX format.

Definition at line 592 of file tex.py.

def pylmflib.pylmflib.output.tex.format_restrictions (   sense,
  font 
)

Display restrictions in LaTeX format.

Parameters
senseThe current Sense LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing restrictions in LaTeX format.

Definition at line 562 of file tex.py.

def pylmflib.pylmflib.output.tex.format_rf (   sense,
  font 
)

Display 'rf' in LaTeX format.

Parameters
lexical_entryThe current Sense LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing 'rf' in LaTeX format.

Definition at line 492 of file tex.py.

def pylmflib.pylmflib.output.tex.format_sc (   sense,
  font 
)

Display 'sc' in LaTeX format.

Parameters
senseThe current Sense LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing 'sc' in LaTeX format.

Definition at line 483 of file tex.py.

def pylmflib.pylmflib.output.tex.format_semantic_domains (   lexical_entry,
  font 
)

Display semantic domains in LaTeX format.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing semantic domains in LaTeX format.

Definition at line 725 of file tex.py.

def pylmflib.pylmflib.output.tex.format_source (   lexical_entry,
  font 
)

Display source in LaTeX format.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing source in LaTeX format.

Definition at line 783 of file tex.py.

def pylmflib.pylmflib.output.tex.format_status (   lexical_entry,
  font 
)

Display status in LaTeX format.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing status in LaTeX format.

Definition at line 792 of file tex.py.

def pylmflib.pylmflib.output.tex.format_table (   lexical_entry,
  font 
)

Display a table in LaTeX format.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing a table in LaTeX format.

Definition at line 717 of file tex.py.

def pylmflib.pylmflib.output.tex.format_uid (   lexical_entry,
  font 
)

Functions to process LaTeX fields (output)

Transform unique identifier of a lexical entry in ASCII format.

Parameters
lexical_entryThe targeted Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing the unique identifier in LaTeX format.

Definition at line 302 of file tex.py.

def pylmflib.pylmflib.output.tex.format_usage_notes (   sense,
  font 
)

Display usage notes in LaTeX format.

Parameters
senseThe current Sense LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing usage notes in LaTeX format.

Definition at line 528 of file tex.py.

def pylmflib.pylmflib.output.tex.format_variant_forms (   lexical_entry,
  font 
)

Display variant forms in LaTeX format.

Parameters
lexical_entryThe current Lexical Entry LMF instance.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
Returns
A string representing variant forms in LaTeX format.

Definition at line 628 of file tex.py.

def pylmflib.pylmflib.output.tex.handle_caps (   text)
Handle small caps.
Replace '°xxx' by '\textsc{xxx}' in translated examples.

Definition at line 274 of file tex.py.

def pylmflib.pylmflib.output.tex.handle_fi (   text)
Replace 'fi:xxx' and '|fi{xxx}' by \\textit{xxx}.

Definition at line 229 of file tex.py.

def pylmflib.pylmflib.output.tex.handle_fn (   text,
  font 
)
Replace 'fn:xxx' and '|fn{xxx}' by font[NATIONAL](xxx).

Definition at line 254 of file tex.py.

def pylmflib.pylmflib.output.tex.handle_font (   text)

Functions to process LaTeX layout.

Replace '{xxx}' by '\ipa{xxx}' in 'un', 'xn', 'gn', 'dn', 'en'.

Definition at line 200 of file tex.py.

def pylmflib.pylmflib.output.tex.handle_fv (   text,
  font 
)
Replace 'fv:xxx' and '|fv{xxx}' by font[VERNACULAR](xxx).

Definition at line 241 of file tex.py.

def pylmflib.pylmflib.output.tex.handle_pinyin (   text)
Replace '@xxx' by '\\textcolor{gray}{xxx}' in 'lx', 'dv', 'xv' fields (already in API).

Definition at line 266 of file tex.py.

def pylmflib.pylmflib.output.tex.handle_quotes (   text)
Hanlde quotation marks.
Replace each "xxx" by ``xxx".

Definition at line 284 of file tex.py.

def pylmflib.pylmflib.output.tex.handle_reserved (   text)
Handle reserved characters $ & % # _ ^ except \ { }.

Definition at line 209 of file tex.py.

def pylmflib.pylmflib.output.tex.insert_references (   lexical_entry)

Insert references to paradigms.

Parameters
lexical_entryThe targeted Lexical Entry LMF instance.
Returns
A string representing the references in LaTeX format.

Definition at line 28 of file tex.py.

def pylmflib.pylmflib.output.tex.tex_write (   object,
  filename,
  preamble = None,
  introduction = None,
  lmf2tex = lmf_to_tex,
  font = None,
  items = lambda lexical_entry: lexical_entry.get_lexeme(),
  sort_order = None,
  paradigms = [],
  tables = [],
  title = None,
  tex_language = None 
)

Write a LaTeX file.

Note that the lexicon must already be ordered at this point. Here, parameters 'items' and 'sort_order' are only used to define chapters.

Parameters
objectThe LMF instance to convert into LaTeX output format.
filenameThe name of the LaTeX file to write with full path, for instance 'user/output.tex'.
preambleThe name of the LaTeX file with full path containing the LaTeX header of the document, for instance 'user/config/japhug.tex'. Default value is None.
introductionThe name of the LaTeX file with full path containing the LaTeX introduction of the document, for instance 'user/config/introduction.tex'. Default value is None.
lmf2texA function giving the mapping from LMF representation information that must be written to LaTeX commands, in a defined order. Default value is 'lmf_to_tex' function defined in 'pylmflib/config/tex.py'. Please refer to it as an example.
fontA Python dictionary giving the vernacular, national, regional fonts to apply to a text in LaTeX format.
itemsLambda function giving the item to sort. Default value is 'lambda lexical_entry: lexical_entry.get_lexeme()', which means that the items to sort are lexemes.
sort_orderDefault value is 'None', which means that the LaTeX output is alphabetically ordered.
paradigmsA Python list of LaTeX filenames with full path containing the paradigms in LaTeX format. Default value is an empty list.
tablesThe name of the LaTeX file with full path containing some notes to add at the end of the LaTeX document, for instance 'user/config/conclusion.tex'. Default value is None.
titleA Python string containing the title of the LaTeX document. Default value is None.
tex_languageA Python string giving the default language to set in LaTeX.

Definition at line 56 of file tex.py.