rdf

package
v0.0.0-...-9d7fed6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContentTypes = map[string]string{
	"epub":            "application/epub+zip",
	"msword":          "application/msword",
	"octet":           "application/octet-stream",
	"finale":          "application/octet-stream; type=\"Finale (mus)\"",
	"license":         "application/octet-stream; type=\"License (license)\"",
	"lilypond":        "application/octet-stream; type=\"LilyPond (ly)\"",
	"md5":             "application/octet-stream; type=\"MD5 Checksum (md5)\"",
	"part":            "application/octet-stream; type=\"Part of ISO CD/DVD Image (iso.split)\"",
	"proprietary":     "application/octet-stream; type=\"Proprietary `Folio' format (nfo)\"",
	"raw":             "application/octet-stream; type=\"Raw Page Images (pageimages)\"",
	"sibelius":        "application/octet-stream; type=\"Sibelius (sib)\"",
	"unspecified":     "application/octet-stream; type=\"Unspecified (?)\"",
	"pdf":             "application/pdf",
	"postscript":      "application/postscript",
	"plucker":         "application/prs.plucker",
	"tei":             "application/prs.tei",
	"tex":             "application/prs.tex",
	"vnd":             "application/vnd.palm",
	"iso9660":         "application/x-iso9660-image",
	"mobi":            "application/x-mobipocket-ebook",
	"mslit":           "application/x-mslit-ebook",
	"qioo":            "application/x-qioo-ebook",
	"zip":             "application/zip",
	"audio_midi":      "audio/midi",
	"audio_mp4":       "audio/mp4",
	"mpeg_audio":      "audio/mpeg",
	"audio_ogg":       "audio/ogg",
	"audio_wma":       "audio/x-ms-wma",
	"audio_wav":       "audio/x-wav",
	"gif":             "image/gif",
	"jpeg":            "image/jpeg",
	"png":             "image/png",
	"tiff":            "image/tiff",
	"html_text":       "text/html",
	"html_kr":         "text/html; charset=euc-kr",
	"html_8859.1":     "text/html; charset=iso-8859-1",
	"html_8859.15":    "text/html; charset=iso-8859-15",
	"html_8859.2":     "text/html; charset=iso-8859-2",
	"html_ascii":      "text/html; charset=us-ascii",
	"html_utf8":       "text/html; charset=utf-8",
	"html_1251":       "text/html; charset=windows-1251",
	"html_1252":       "text/html; charset=windows-1252",
	"html_1253":       "text/html; charset=windows-1253",
	"plain_text":      "text/plain",
	"plain_big5":      "text/plain; charset=big5",
	"plain_kr":        "text/plain; charset=euc-kr",
	"plain_437":       "text/plain; charset=ibm437",
	"plain_850":       "text/plain; charset=ibm850",
	"plain_8859.1":    "text/plain; charset=iso-8859-1",
	"plain_8859.15":   "text/plain; charset=iso-8859-15",
	"plain_8859.2":    "text/plain; charset=iso-8859-2",
	"plain_8859.3":    "text/plain; charset=iso-8859-3",
	"plain_8859.7":    "text/plain; charset=iso-8859-7",
	"plain_mac":       "text/plain; charset=macintosh",
	"plain_ascii":     "text/plain; charset=us-ascii",
	"plain_utf16":     "text/plain; charset=utf-16",
	"plain_utf8":      "text/plain; charset=utf-8",
	"plain_1250":      "text/plain; charset=windows-1250",
	"plain_1251":      "text/plain; charset=windows-1251",
	"plain_1252":      "text/plain; charset=windows-1252",
	"plain_1253":      "text/plain; charset=windows-1253",
	"plain_other":     "text/plain; charset=x-other",
	"rtf":             "text/rtf",
	"rtf_8859.1":      "text/rtf; charset=iso-8859-1",
	"rtf_ascii":       "text/rtf; charset=us-ascii",
	"rst":             "text/x-rst",
	"xml":             "text/xml",
	"xml_8859.1":      "text/xml; charset=iso-8859-1",
	"video_mpeg":      "video/mpeg",
	"video_quicktime": "video/quicktime",
	"video_ms":        "video/x-msvideo",
}

ContentTypes are friendly names for the data file formats that occur in the dataset.

Functions

This section is empty.

Types

type EBookFilter

type EBookFilter func(*booktypes.EBook) bool

EBookFilter is a function that evaluates an EBook object and returns true if the object "passes". Only if an object passes all filters is it included in the output.

func LanguageFilter

func LanguageFilter(languages ...string) EBookFilter

LanguageFilter is a convenience function that returns an EBookFilter which returns true if the ebook is in any of the languages specified.

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader loads an RDF file given a reader to it

func NewLoader

func NewLoader(r io.Reader, options ...LoaderOption) *Loader

NewLoader constructs an RDF Loader from a reader.

func (*Loader) Load

func (r *Loader) Load(rdr io.Reader) []booktypes.EBook

Load is a helper function used by the Load functions

func (*Loader) LoadOne

func (r *Loader) LoadOne() ([]booktypes.EBook, int)

LoadOne parses and loads the XML data within its contents, expecting the contents to be a single file containing one or more EBook entities. It only returns the entities that pass the filters that have been set up before calling load. Returns 1 (the number of files processed).

func (*Loader) LoadTar

func (r *Loader) LoadTar() ([]booktypes.EBook, int)

LoadTar loads from a reader, expecting the reader to be a tar file that contains lots of files of books It returns a slide of EBooks and the number of files that were processed within the tar. If loadOnly is set, it limits the number of items loaded. This is mainly useful for testing.

type LoaderOption

type LoaderOption func(*Loader)

LoaderOption is the type of a function used to set loader options; It modifies the Loader passed into it.

func EBookFilterOpt

func EBookFilterOpt(f EBookFilter) LoaderOption

EBookFilterOpt returns a LoaderOption that adds an EBookFilter

func LoadAtMostOpt

func LoadAtMostOpt(n int) LoaderOption

LoadAtMostOpt returns a LoaderOptions that limits the number of items loaded

func PGFileFilterOpt

func PGFileFilterOpt(f PGFileFilter) LoaderOption

PGFileFilterOpt returns a LoaderOption that adds a PGFileFilter

func UntarOpt

func UntarOpt(n int) LoaderOption

UntarOpt returns a LoaderOptions that wraps the reader in a tar reader

type PGFileFilter

type PGFileFilter func(*booktypes.PGFile) bool

PGFileFilter is a function that evaluates an PGFile object and returns true if the object "passes". Only if an object passes all filters is it included in the output.

func ContentFilter

func ContentFilter(contentTypes ...string) PGFileFilter

ContentFilter is a convenience function that returns a PGFileFilter which returns true if the file has a matching prefix of for any one of the specified content types. Some files have two content types -- the base type, and Zip (if there is a zipped version of the file).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL