linguappt package

Submodules

linguappt.lib module

linguappt.lib.pdf2images(pdfpath, imgfolder='./', start=0, end=None)

Convert pdf into images

Parameters
  • pdfpath (str) – pdf file path

  • imgfolder (str) – image folder. Default is current folder

  • start (int) – start page of pdf

  • end (int) – end page pdf

Returns

number of images stored

Return type

int

linguappt.lib.pptx2pdf(pptx, pdffolder='./')

Convert pptx into pdf

Parameters
  • pptx (str) – pptx file

  • pdffile (str) – folder that the pdf is stored in

Returns

pdf file path

Return type

str

linguappt.lib.readCSV(filename)

Read csv file

Parameters

filename (str) – csv file name

Returns

records in csv file

Return type

list of dict

linguappt.lib.read_json(jsonfile)

linguappt.phrase_ppt module

class linguappt.phrase_ppt.PhrasePPT(sourcefile, title='', genre='classic')

Bases: object

It is designed as an abstract class to be inheritated for phrase ppt generation of different languages,

Note

DON’T use this class directly. To define a PhrasePPT for a lanugage

  1. Define subclass inheriting PhrasePPT, e.g, ChinesePhrasePPT

  2. Define class variable _templates, which is a dict, key is template genre, value is template path

  3. Define class varibale content_keys, which is a list, containing the heads in csv file

  4. Implement method _create_phrase(self)

convert_to_ppt(destfile='test.pptx')

Convert csv file containing vocabulary information into pptx file

Parameters

destfile (str) – pptx file path

linguappt.structure_kg_ppt module

class linguappt.structure_kg_ppt.StructureKGPPT(sourcefile, title='', genre='classic')

Bases: object

It is designed as an abstract class to be inheritated for phrase ppt generation of different languages,

Note

DON’T use this class directly. To define a StructureKGPPT for a lanugage

  1. Define subclass inheriting StructureKGPPT, e.g, ChineseStructureKGPPT

  2. Define class variable _templates, which is a dict, key is template genre, value is template path

  3. Define class varibale content_keys, which is a list, containing the heads in csv file

  4. Implement method _create_structure_kg(self)

convert_to_ppt(destfile='test.pptx')

Convert csv file containing vocabulary information into pptx file

Parameters

destfile (str) – pptx file path

linguappt.vocab_ppt module

class linguappt.vocab_ppt.VocabPPT(sourcefile, title='', genre='classic')

Bases: object

It is designed as an abstract class to be inheritated for vocabulary ppt generation of different languages,

Note

DON’T use this class directly. To define a VocabPPT for a lanugage

  1. Define subclass inheriting VocabPPT, e.g, ChineseVocabPPT

  2. Define class variable _templates, which is a dict, key is template genre, value is template path

  3. Define class variable content_keys, which is a list, containing the heads in csv file

  4. Implement methods _create_noun(self, v), _create_verb(self, v), _create_adj(self, v), where v is a vocab object, corresponding to a record (one line) in csv file

convert_to_ppt(destfile='test.pptx')

Convert csv file containing vocabulary information into pptx file

Parameters

destfile (str) – pptx file path

Module contents

linguappt Package

This module demostrates the usage of package linguappt.

Installation

$ pip3 install linguappt

Use as executable

$ lingua_vocabppt --sourcecsv [vocab csv file] --lang [language] --title [title shown in ppt] --destpptx [pptx file]

$ lingua_phraseppt --sourcecsv [phrase csv file] --lang [language] --title [title shown in ppt] --destpptx [pptx file]

$ lingua_pptx2pdf --sourcepptx [pptx file] --destdir [dest directory storing pdf and images]

Convert csv file containing vocabulary informatin into pptx file

from linguappt import SpanishVocabPPT, EnglishVocabPPT

def vocabppt(sourcecsv, title, lang, destpptx):
  _PPTS = {
    "en": EnglishVocabPPT,
    "es": SpanishVocabPPT
  }

  _PPT = _PPTS[lang]

  vp = _PPT(sourcecsv, title)
  vp.convert_to_ppt(destpptx)

Convert csv file containing vocabulary informatin into pptx file

from linguappt import EnglishPhrasePPT, SpanishPhrasePPT

def phraseppt(sourcecsv, title, lang, destpptx):
  _PPTS = {
    "en": EnglishPhrasePPT,
    "es": SpanishPhrasePPT
  }

  _PPT = _PPTS[lang]

  vp = _PPT(sourcecsv, title)
  vp.convert_to_ppt(destpptx)