Documentation ¶
Index ¶
- Constants
- Variables
- type Actor
- type Line
- type RawLine
- type Script
- type ScriptParser
- func (s *ScriptParser) CreateDialogueRegex(prefixRegexp, actorRegexp, postfixRegexp string, isMultiLineDialogue bool)
- func (s *ScriptParser) LoadTranscript(reader io.Reader) *Script
- func (s *ScriptParser) LoadTranscriptFromFilePath(filepath string)
- func (s *ScriptParser) UseSkipRegexps(skipRegexps []*regexp.Regexp)
- type SearchFunction
- type StringComparator
- type StringSimplifier
Constants ¶
const NON_ACTOR = Actor("")
Variables ¶
var StringComparatorExactSearch = StringComparator(func(s1 string, s2 string) bool { return s1 == s2 })
StringComparatorExactSearch `script.CreateSearchFunction(StringComparatorExactSearch)` gives you a SearchFunction that will look for a Line with an exact match with the target. Functions of the type StringSimplifier can be used to simplify strings before comparison.
var StringComparatorSubsetSearch = StringComparator(strings.Contains)
StringComparatorSubsetSearch `script.CreateSearchFunction(StringComparatorSubsetSearch)` gives you a SearchFunction that will look for a Line with a subset that matches the target. Functions of the type StringSimplifier can be used to simplify strings before comparison.
var StringSimplifierAlphabetOnly = StringSimplifierSkipIfRune(func(r rune) bool {
return r >= 'a' && r <= 'z' || r >= 'A' && r <= 'Z'
})
StringSimplifierAlphabetOnly is a StringSimplifier that extracts only alphabets from the string
var StringSimplifierIgnoreCase = StringSimplifier(strings.ToUpper)
StringSimplifierIgnoreCase is a StringSimplifier that will have the comparator ignoring case
Functions ¶
This section is empty.
Types ¶
type Script ¶
func (Script) CreateSearchFunction ¶
func (s Script) CreateSearchFunction(comparator StringComparator, simplifiers ...StringSimplifier) SearchFunction
type ScriptParser ¶
type ScriptParser struct {
// contains filtered or unexported fields
}
func (*ScriptParser) CreateDialogueRegex ¶
func (s *ScriptParser) CreateDialogueRegex(prefixRegexp, actorRegexp, postfixRegexp string, isMultiLineDialogue bool)
CreateDialogueRegex creates a regexp pattern for identifying the start of a dialogue. Note that it will be combined in the form: `^{prefixRegexp}{actorRegexp}{postfixRegexp}{dialogue}`. If isMultiString is turned on, dialogue will include every line afterwards until `^{prefixRegexp}{actorRegexp}{postfixRegexp}` is found on the next line. Do not use capturing groups inside the input regexp. Note: any errors will cause a panic to simplify client code.
func (*ScriptParser) LoadTranscript ¶
func (s *ScriptParser) LoadTranscript(reader io.Reader) *Script
func (*ScriptParser) LoadTranscriptFromFilePath ¶
func (s *ScriptParser) LoadTranscriptFromFilePath(filepath string)
LoadTranscriptFromFilePath will attempt to load from filepath, and panic immediately if it does not work.
func (*ScriptParser) UseSkipRegexps ¶
func (s *ScriptParser) UseSkipRegexps(skipRegexps []*regexp.Regexp)
UseSkipRegexps to skip over non-dialogue lines if isMultilineDialog is turned on. Unlike CreateDialogRegex, this is not combined with anything else and will be used as is. As such, the regex should use ^ and $ to ensure multiline dialogs that contain a match do not get skipped over. Note: Only has an effect if isMultilineDialog is true.
type SearchFunction ¶
type StringComparator ¶
func CreateWildcardComparator ¶
func CreateWildcardComparator(wildcard regexp.Regexp) StringComparator
CreateWildcardComparator creates a wildcard aware StringComparator. It takes in a wildcard regex pattern and treats any matches in the target string as wildcards. Note that it only looks to match the resulting target as a subset of dialogues, not an exact match.
type StringSimplifier ¶
func StringSimplifierSkipIfRune ¶
func StringSimplifierSkipIfRune(skipIfTrue func(r rune) bool) StringSimplifier