Documentation ¶
Index ¶
- Constants
- func GetArrayFromJsonByPath(data []byte, path string) ([]*gabs.Container, error)
- func IsWordValid(word string) bool
- func ReadFileContent(file string) (string, error)
- func RunHttpRequest(url string, optional ...map[string]interface{}) ([]byte, error)
- func SeekFileLocation(location string, envVariableName string) (string, error)
- type AdvanceSuffleRule
- type CambridgeRule
- type DLGlosbe
- type DLPearson
- type DictionaryLookup
- type DictionaryLookupEngine
- type DictionaryLookupResult
- type DictionaryMatcher
- type GramSequencer
- type MatcherRule
- type SequenceShufflerRule
- type ShuffleRule
- type Shuffler
Constants ¶
const DefaultDictionaryCacheSize = 20
const DefaultDictionaryLocation = "words_alpha.txt"
default dictionary path
const EnvVariableDictLocation = "MATCHER_DICT_LOCATION"
default environment variable name => "MATCHER_DICT_LOCATION"
const KeyLangFrom = "key_lang_from"
const KeyLangTo = "key_lang_to"
const LookupOperationType = "lookup_operation_type"
Variables ¶
This section is empty.
Functions ¶
func GetArrayFromJsonByPath ¶
func IsWordValid ¶
handy method to check if the given word is valid (not just space)
func ReadFileContent ¶
read the contents of a given file
func RunHttpRequest ¶
run an http request based on the given url, an optional map object could be supplied for optional parameters
Types ¶
type AdvanceSuffleRule ¶
type DLGlosbe ¶
type DLGlosbe struct {
// contains filtered or unexported fields
}
func NewGlosbeEngine ¶
func NewGlosbeEngine() *DLGlosbe
type DLPearson ¶
type DLPearson struct {
// contains filtered or unexported fields
}
func NewPearsonEngine ¶
func NewPearsonEngine() *DLPearson
type DictionaryLookup ¶
type DictionaryLookup struct {
// contains filtered or unexported fields
}
func NewDictionaryLookup ¶
func NewDictionaryLookup(cacheSize ...int) *DictionaryLookup
create a new instance of DictionaryLookup with an optional cache size; if the cache size is not given, the default size of "20" is used
func (*DictionaryLookup) Lookup ¶
func (d *DictionaryLookup) Lookup(word string, optionalParams map[string]interface{}) ([]DictionaryLookupResult, error)
type DictionaryLookupEngine ¶
type DictionaryLookupEngine interface { // returns an arbitrary string to describe the lookup engine (e.g. webster dictionary api) Source() string // do the lookup for the given "word", wraps the results into // an array of DictionaryLookupResult Lookup(word string, optionalParams map[string]interface{}) ([]DictionaryLookupResult, error) }
interface for a dictionary lookup engine / approach
type DictionaryLookupResult ¶
func NewDictionaryLookupResult ¶
func NewDictionaryLookupResult(text, lang string) DictionaryLookupResult
return a new instance of the lookup result
type DictionaryMatcher ¶
type DictionaryMatcher struct {
// contains filtered or unexported fields
}
Matcher implementation based on the Matcher interface involves efficient indexing of the chunk of dictionary entries (e.g. lazy loading of dictionary sections based word prefix match)
func NewDictionaryMatcher ¶
func NewDictionaryMatcher(location ...string) DictionaryMatcher
create a new instance of DictionaryMatcher
type GramSequencer ¶
type GramSequencer struct { // the sequence involved for "word" formation and matching later on Sequence string // contains filtered or unexported fields }
func NewGramSequencer ¶
func NewGramSequencer(sequence string, minSeqSize, maxSeqSize int, matcherRule MatcherRule, shuffleRule AdvanceSuffleRule) GramSequencer
method to create an instance of GramSequencer
func NewGramSequencerSimple ¶
func NewGramSequencerSimple(sequence string) GramSequencer
method to create an instance of GramSequencer
func (*GramSequencer) GenerateValidSequences ¶
func (g *GramSequencer) GenerateValidSequences() error
method to generate "valid" sequences created from the given sequence. Valid or not depends on the implementation of the Matcher
func (*GramSequencer) GetValidSequences ¶
func (g *GramSequencer) GetValidSequences() []string
simple getter
type MatcherRule ¶
type MatcherRule interface { // method to match the given word against a "source"; could be a dictionary. MatchWord(word string) (bool, error) }
interface encapsulating matching rules with a "source" (e.g. dictionary)
type SequenceShufflerRule ¶
type SequenceShufflerRule struct { // the minimum size of the "words" to be created from the given sequence. // Theoretically it should be at least "2" MinGramSize int // optional size threshold for the sequence generation (remember the // longer is the sequence, the more computation is required) MaxGramSize int // contains filtered or unexported fields }
func NewSequenceShufflerRule ¶
func NewSequenceShufflerRule(minSize, maxSize int, sequence string) SequenceShufflerRule
create a new instance of SequenceShufflerRule
type ShuffleRule ¶
type ShuffleRule interface { // shuffle the given / old text based on its unique rules Shuffle(oldText string) (string, error) }
interface encapsulating shuffling rules
type Shuffler ¶
type Shuffler struct { // location of the file containing the text (could be empty value "") Location string // Shuffle Rule Rule ShuffleRule // contains filtered or unexported fields }
func NewShuffler ¶
func NewShuffler(location string, shuffleRule ...ShuffleRule) Shuffler
func (*Shuffler) GetShuffleGrams ¶
return the shuffled / new grams
func (*Shuffler) GetShuffleText ¶
return the shuffled / new text