{"modulePath":"github.com/opencloud-eu/opencloud","version":"v1.1.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package preprocessor\n\n## Variables\n\n```go\nvar DefaultMergeMap = MergeMap{\n\t\"Han\": map[string]string{\n\t\t\"Hiragana\": \"Hiragana\",\n\t\t\"Katakana\": \"Katakana\",\n\t},\n\t\"Hiragana\": map[string]string{\n\t\t\"Han\":      \"Hiragana\",\n\t\t\"Katakana\": \"Hiragana\",\n\t},\n\t\"Katakana\": map[string]string{\n\t\t\"Han\":      \"Katakana\",\n\t\t\"Hiragana\": \"Hiragana\",\n\t},\n}\n```\nThe default mergeMap containing info for the japanese scripts\n\n```go\nvar DefaultScripts = []string{\n\t\"Arabic\",\n\t\"Common\",\n\t\"Devanagari\",\n\t\"Han\",\n\t\"Hangul\",\n\t\"Hiragana\",\n\t\"Inherited\",\n\t\"Katakana\",\n\t\"Latin\",\n}\n```\nDefault list of scripts to be analyzed within the string.\n\nScripts that aren't present in the list will be considered as part of the last \"known\" script. For example, if \"Avestan\" script (which isn't present) is preceeded by \"Arabic\" script, then the \"Avestan\" script will be considered as \"Arabic\"\n\nPunctuation symbols are usually considered part of the \"Common\" script\n\n## Types\n\n```go\ntype AnalysisOpts struct {\n\tUseMergeMap bool\n\tMergeMap    MergeMap\n}\n```\nAnalysis options.\n\n```go\ntype AudioDecoder struct{}\n```\nAudioDecoder is a converter for the audio file\n\n```go\nfunc (i AudioDecoder) Convert(r io.Reader) (interface{}, error)\n```\nConvert reads the audio file and extracts the thumbnail image from the id3 tag\n\n```go\ntype FileConverter interface {\n\tConvert(r io.Reader) (interface{}, error)\n}\n```\nFileConverter is the interface for the file converter\n\n```go\nfunc ForType(mimeType string, opts map[string]interface{}) FileConverter\n```\nForType returns the converter for the specified mimeType\n\n```go\ntype FontLoader struct {\n\t// contains filtered or unexported fields\n}\n```\nFontLoader represents a FontLoader. Use the \"NewFontLoader\" to get a instance\n\n```go\nfunc NewFontLoader(fontMapFile string, faceOpts *opentype.FaceOptions) (*FontLoader, error)\n```\nNewFontLoader creates a new FontLoader based on the fontMapFile. The FaceOptions will be the same for all the font loaded by this instance. Note that only the fonts described in the fontMapFile will be used.\n\nThe fontMapFile has the following structure\n\n\t{\n\t\t\"fontMap\": {\n\t\t\t\"Han\": \"packaged/myFont-CJK.otf\",\n\t\t\t\"Arabic\": \"packaged/myFont-Arab.otf\",\n\t\t\t\"Latin\": \"/fonts/regular/myFont.otf\"\n\t\t}\n\t\t\"defaultFont\": \"/fonts/regular/myFont.otf\"\n\t}\n\nThe fontMapFile contains paths to where the fonts are located in the FS. Absolute paths can be used as shown above. If a relative path is used, it will be relative to the fontMapFile location. This should make the packaging easier since all the fonts can be placed in the same directory where the fontMapFile is, or in inner directories.\n\n```go\nfunc (fl *FontLoader) GetFaceOptDPI() float64\n```\nGetFaceOptDPI returns face opt DPI\n\n```go\nfunc (fl *FontLoader) GetFaceOptSize() float64\n```\nGetFaceOptSize returns face opt size\n\n```go\nfunc (fl *FontLoader) GetScriptList() []string\n```\nGetScriptList returns script list\n\n```go\nfunc (fl *FontLoader) LoadFaceForScript(script string) (*LoadedFace, error)\n```\nLoadFaceForScript loads and returns the font face to be used for that script according to the FontMap set when the FontLoader was created. If the script doesn't have an associated font, a default font will be used. Note that the default font might not be able to handle properly the script\n\n```go\ntype FontMap struct {\n\tFontMap     map[string]string `json:\"fontMap\"`\n\tDefaultFont string            `json:\"defaultFont\"`\n}\n```\nFontMap maps a script with the target font to be used for that script It also uses a DefaultFont in case there isn't a matching script in the map\n\nFor cases like Japanese where multiple scripts are used, we rely on the text analyzer to use the script which is unique to japanese (Hiragana or Katakana) even if it has to overwrite the \"official\" detected script (Han). This means that \"Han\" should be used just for chinese while \"Hiragana\" and \"Katakana\" should be used for japanese\n\n```go\ntype FontMapData struct {\n\tFMap *FontMap\n\tFLoc string\n}\n```\nFontMapData contains the location of the loaded file (in FLoc) and the FontMap loaded from the file\n\n```go\ntype GGPStruct struct {\n\tSections []struct {\n\t\tCards []struct {\n\t\t\tElement struct {\n\t\t\t\tImage struct {\n\t\t\t\t\tBase64Image string\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n```\nGGPStruct is the layout of a ggp file (which is basically json)\n\n```go\ntype GgpDecoder struct{}\n```\nGgpDecoder is a converter for the geogebra pinboard file\n\n```go\nfunc (j GgpDecoder) Convert(r io.Reader) (interface{}, error)\n```\nConvert reads the ggp file and returns the first thumbnail image\n\n```go\ntype GgsDecoder struct {\n\t// contains filtered or unexported fields\n}\n```\nGgsDecoder is a converter for the geogebra slides file\n\n```go\nfunc (g GgsDecoder) Convert(r io.Reader) (interface{}, error)\n```\nConvert reads the ggs file and returns the thumbnail image\n\n```go\ntype GifDecoder struct{}\n```\nGifDecoder is a converter for the gif file\n\n```go\nfunc (i GifDecoder) Convert(r io.Reader) (interface{}, error)\n```\nConvert reads the gif file and returns the thumbnail image\n\n```go\ntype ImageDecoder struct{}\n```\nImageDecoder is a converter for the image file\n\n```go\nfunc (i ImageDecoder) Convert(r io.Reader) (interface{}, error)\n```\nConvert reads the image file and returns the thumbnail image\n\n```go\ntype LoadedFace struct {\n\tFontFile string\n\tFace     font.Face\n}\n```\nLoadedFace contains the location of the font used, and the loaded face (font.Face) ready to be used\n\n```go\ntype MergeMap map[string]map[string]string\n```\nConvenient map\\[string]map\\[string]string type used to merge multiple scripts into one. This is mainly used for japanese language which uses \"Han\", \"Hiragana\" and \"Katakana\" scripts.\n\nThe map contains the expected previous script as first key, the expected current script as second key, and the resulting script (if both keys match) as value\n\n```go\ntype ScriptRange struct {\n\tLow, High    int\n\tSpaces       []int\n\tTargetScript string\n\tRuneCount    int\n}\n```\nA script range. The range should be attached to a string which could contain multiple scripts. The \"TargetScript\" will go from bytes \"Low\" to \"High\" (both inclusive), and contains a \"RuneCount\" number of runes or chars (mostly for debugging purposes). The Space contains the bytes (inside the range) that are considered as white space.\n\n```go\ntype TextAnalysis struct {\n\tScriptRanges []ScriptRange\n\tRuneCount    map[string]int\n\tText         string\n}\n```\nThe result of a text analysis. It contains the analyzed text, a list of script ranges (see the ScriptRange type) and a map containing how many runes have been detected for a particular script.\n\n```go\nfunc (tr *TextAnalysis) MergeCommon(mergeMap MergeMap)\n```\nChange the \"Common\" script to the one used in the previous script range. The ranges will be readjusted and merged if they're adjacent. This naive approach should be good enough for normal use cases\n\nThe MergeMap is needed in case of the japanese language: the ranges \"Han\"-\"Common\"-\"Katakana\" might be replaced to \"Han\"-\"Hiragana\"-\"Katakana\" However, the ranges should be merged together into a big \"Hiragana\" range. If the MergeMap isn't needed, use an empty one\n\n```go\ntype TextAnalyzer struct {\n\t// contains filtered or unexported fields\n}\n```\nThe TextAnalyzer object contains private members. It should be created via \"NewTextAnalyzer\" function.\n\n```go\nfunc NewTextAnalyzer(scriptList []string) TextAnalyzer\n```\nCreate a new TextAnalyzer. A list of scripts must be provided. You can use the \"DefaultScripts\" variable for a default list, although it doesn't contain all the available scripts. See the unicode.Scripts variable (in the unicode package) for a full list. Note that using invalid scripts will cause an undefined behavior\n\n```go\nfunc (ta *TextAnalyzer) AnalyzeString(word string, opts AnalysisOpts) TextAnalysis\n```\nAnalyze the target string using the specified options. A TextAnalysis will be returned with the result of the analysis.\n\n```go\ntype TxtToImageConverter struct {\n\t// contains filtered or unexported fields\n}\n```\nTxtToImageConverter is a converter for the text file\n\n```go\nfunc (t TxtToImageConverter) Convert(r io.Reader) (interface{}, error)\n```\nConvert reads the text file and renders it into a thumbnail image\n\n","path":"github.com/opencloud-eu/opencloud/services/thumbnails/pkg/preprocessor","name":"preprocessor","synopsis":"","isRedistributable":true}
