// NewHelper : creates a new submatch helper from a regexp struct
549667
func NewHelper(r *regexp.Regexp) (sm Helper) {
	sm.IndexMap = make(map[string]int)
	for i, name := range r.SubexpNames() {
		sm.IndexMap[name] = i
	}
	sm.timeLayout = time.RFC3339
	sm.regex = r
	return
}
162372
func newLexer(input, left, right string) *lexer {
	l := &lexer{
		input:      input,
		leftDelim:  left,
		rightDelim: right,
		tokens:     make(chan token, 2),
	}
	l.state = stateText // initial state
	return l
}
640665
func (tpl *Template) RegisterHelper(name string, helper interface{}) {
	tpl.mutex.Lock()
	defer tpl.mutex.Unlock()

	if tpl.helpers[name] != zero {
		panic(fmt.Sprintf("Helper %s already registered", name))
	}

	val := reflect.ValueOf(helper)
	ensureValidHelper(name, val)

	tpl.helpers[name] = val
}
495852
func (m *Mux) AddMatcher(matchers ...Matcher) *Mux {
	m.Matchers = append(m.Matchers, matchers...)
	return m
}
1251587
func NewLocationHelper(ix *Index) *LocationHelper {
	lh := &LocationHelper{index: ix}
	if ix.corpus != nil {
		lh.corpus = ix.corpus
	}
	return lh
}
251873
func (c *BaseCommand) TokenHelper() (token.TokenHelper, error) {
	if c.tokenHelper != nil {
		return c.tokenHelper, nil
	}

	helper, err := DefaultTokenHelper()
	if err != nil {
		return nil, err
	}
	return helper, nil
}
1213421
func NewDecoder(r io.Reader) *Decoder {
	return &Decoder{Decoder: *json.NewDecoder(r)}
}
291833
func (j JsonHelper) Helpers(n string) []JsonHelper {
	v := j.Get(n)
	if v == nil {
		return nil
	}
	switch val := v.(type) {
	case []map[string]interface{}:
		hl := make([]JsonHelper, 0)
		for _, mapVal := range val {
			hl = append(hl, mapVal)
		}
		return hl
	case []interface{}:
		jhl := make([]JsonHelper, 0)
		for _, item := range val {
			if jh, ok := item.(map[string]interface{}); ok {
				jhl = append(jhl, jh)
			}
		}
		return jhl
	}

	return nil
}
708229
func NewGenerator(regex string) (*Generator, error) {
	re, err := syntax.Parse(regex, syntax.Perl)
	if err != nil {
		return nil, err
	}
	//fmt.Println("Compiled re ", re)
	return &Generator{
		re:   re,
		rand: rand.New(rand.NewSource(time.Now().UnixNano())),
	}, nil
}
1188470
func NewQuasiNewtonHelper(numHist int, minimizer Minimizer, curPos *core.Vector, curGrad *core.Vector) *QuasiNewtonHelper {
	h := new(QuasiNewtonHelper)
	h.numHist = int64(numHist)
	h.minimizer = minimizer
	h.curPos = curPos
	h.curGrad = curGrad
	h.sList = make([]*core.Vector, 0)
	h.yList = make([]*core.Vector, 0)
	h.roList = make([]float64, 0)
	return h
}
1037288
func NewDecoder(r io.Reader) *Decoder {
	return &Decoder{r, defaultDelimiter, defaultEscape, false, false}
}
406849
func NewUserHelperWriter(filename string) (*UserHelperWriter, error) {
	file, err := codegen.SourceFileFor(filename)
	if err != nil {
		return nil, err
	}
	return &UserHelperWriter{SourceFile: file}, nil
}
1277801
func NewMatcher(dictionary [][]byte) *Matcher {
	m := new(Matcher)

	m.buildTrie(dictionary)

	return m
}
885270
func NewRegexpFilter(name, regexp string) RegexpFilter {
	return RegexpFilter{name: name, regexp: regexp}
}
80001
func normalizeHelper(number string,
	normalizationReplacements map[rune]rune,
	removeNonMatches bool) string {

	var normalizedNumber = builder.NewBuilder(nil)
	for _, character := range number {
		newDigit, ok := normalizationReplacements[unicode.ToUpper(character)]
		if ok {
			normalizedNumber.WriteRune(newDigit)
		} else if !removeNonMatches {
			normalizedNumber.WriteRune(character)
		}
		// If neither of the above are true, we remove this character.
	}
	return normalizedNumber.String()
}
895983
func NewOperator(token int, lexeme string) (Operator, error) {
	switch token {
	case parser.EqualityToken:
		return equalityOperator, nil
	case parser.LeftDipleToken:
		return lessThanOperator, nil
	case parser.RightDipleToken:
		return greaterThanOperator, nil
	case parser.LessOrEqualToken:
		return lessOrEqualOperator, nil
	case parser.GreaterOrEqualToken:
		return greaterOrEqualOperator, nil
	}

	return nil, fmt.Errorf("Operator '%s' does not exist", lexeme)
}
926680
func SearchHelp() string {
	type help struct{ Name, Description string }
	h := []help{}
	for _, p := range keywords {
		h = append(h, help{p.Name(), p.Description()})
	}
	b, err := json.MarshalIndent(h, "", "  ")
	if err != nil {
		return "Error marshalling"
	}
	return string(b)
}