parser

package
v0.0.0-...-c4d1539 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CsvParser

type CsvParser struct {
}

func (CsvParser) ConvertDemo

func (x CsvParser) ConvertDemo(unprocessed []byte) (Demo, error)

func (CsvParser) ConvertSource

func (x CsvParser) ConvertSource(i []byte) (Source, error)

type CsvRow

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

type Demo

type Demo = swagger.Demo

func ConvertDemo

func ConvertDemo(unprocessed []byte, t DocumentType) (Demo, error)

/ ConvertDemo

type DocXParser

type DocXParser struct {
}

DocxParser implements the converter interface

func (DocXParser) ConvertDemo

func (t DocXParser) ConvertDemo(i []byte) (Demo, error)

func (DocXParser) ConvertSource

func (t DocXParser) ConvertSource(unprocessed []byte) (Source, error)

Convert unzips the docx file, finds the content (document.xml), parses the xml tree, and finally walks the xml tree in a top down fashion

type DocumentType

type DocumentType int
const (
	Text DocumentType = iota
	DocX
	Xlsx
	Csv
)

type Paragraph

type Paragraph = swagger.Paragraph

type Parser

type Parser interface {
	ConvertSource([]byte) (Source, error)
	ConvertDemo([]byte) (Demo, error)
}

func NewParser

func NewParser(t DocumentType) (Parser, error)

GetParser returns the matching parser for the filetype or error if there is no correct parser

type Sentence

type Sentence = swagger.Sentence

type Source

type Source = swagger.Source

func ConvertSource

func ConvertSource(unprocessed []byte, t DocumentType) (Source, error)

ConvertSource takes the bytes from a file and the file type and generates a simple intermediate representation which can be manipulated.

type TxtParser

type TxtParser struct {
}

func (TxtParser) ConvertDemo

func (t TxtParser) ConvertDemo(bytes []byte) (Demo, error)

func (TxtParser) ConvertSource

func (t TxtParser) ConvertSource(unprocessed []byte) (Source, error)

Convert for the TxtParser does not fail since it simply reads from the start of the bytes to the end It makes fairly arbitrary choices for how to handle certain datatypes.

type XlsxParser

type XlsxParser struct {
}

func (XlsxParser) ConvertDemo

func (x XlsxParser) ConvertDemo(unprocessed []byte) (Demo, error)

func (XlsxParser) ConvertSource

func (x XlsxParser) ConvertSource(i []byte) (Source, error)

Jump to

Keyboard shortcuts

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