// Classify returns true on errors that are retryable
359043
func (cg ClassifierGroup) Classify(err error) bool {
	for _, classifier := range cg {
		if classifier.Classify(err) {
			return true
		}
	}
	return false
}
755182
func (p *Partition) Class(w string) (int, error) {
	n, ok := p.words[w]
	if !ok {
		return 0, &NotFoundError{w}
	}
	return n, nil
}
471827
func (r *StopRetrier) Retry(ctx context.Context, retry int, req *http.Request, resp *http.Response, err error) (time.Duration, bool, error) {
	return 0, false, nil
}
734114
func (e *EvalEligibility) GetClasses() map[string]bool {
	elig := make(map[string]bool)

	// Go through the task groups.
	for _, classes := range e.taskGroups {
		for class, feas := range classes {
			switch feas {
			case EvalComputedClassEligible:
				elig[class] = true
			case EvalComputedClassIneligible:
				// Only mark as ineligible if it hasn't been marked before. This
				// prevents one task group marking a class as ineligible when it
				// is eligible on another task group.
				if _, ok := elig[class]; !ok {
					elig[class] = false
				}
			}
		}
	}

	// Go through the job.
	for class, feas := range e.job {
		switch feas {
		case EvalComputedClassEligible:
			// Only mark as eligible if it hasn't been marked before. This
			// prevents the job marking a class as eligible when it is ineligible
			// to all the task groups.
			if _, ok := elig[class]; !ok {
				elig[class] = true
			}
		case EvalComputedClassIneligible:
			elig[class] = false
		}
	}

	return elig
}
1225021
func (c *RetryError) Error() string {
	if c.Err == nil {
		return c.Message
	}
	return c.Err.Error()
}
462658
func detectType(v interface{}) Type {
	if v == nil {
		return Tnil
	}
	switch v.(type) {
	case bool:
		return Tbool
	case int, int32, int64:
		return Tint64
	case float32, float64:
		return Tfloat64
	case string:
		return Tstring
	case []interface{}:
		return Tarray
	case map[string]interface{}:
		return Tmap
	default:
		return Tunknown
	}
}
864745
func (s *XMLClassifier) SetClassification(v string) *XMLClassifier {
	s.Classification = &v
	return s
}
117468
func isCodeRetryable(statusCode int) bool {
	if _, ok := retryableStatusCodes[statusCode]; ok {
		return true
	}

	return false
}
410319
func (inv *Investigate) Categorizations(domains []string, labels bool) (map[string]DomainCategorization, error) {
	uri, err := catUri("", labels)
	if err != nil {
		inv.Logf("%v", err)
		return nil, err
	}
	body, err := json.Marshal(domains)

	if err != nil {
		inv.Logf("Error marshalling domain slice into JSON: %v", err)
		return nil, err
	}

	resp := make(map[string]DomainCategorization)
	err = inv.PostParse(uri, bytes.NewReader(body), resp)
	if err != nil {
		return nil, err
	}

	return resp, nil
}
633564
func (r Provisioning_Maintenance_Classification) GetMaintenanceClassification(maintenanceClassificationId *int) (resp []datatypes.Provisioning_Maintenance_Classification, err error) {
	params := []interface{}{
		maintenanceClassificationId,
	}
	err = r.Session.DoRequest("SoftLayer_Provisioning_Maintenance_Classification", "getMaintenanceClassification", params, &r.Options, &resp)
	return
}
1275714
func ReloadKNNClassifier(filePath string) (*KNNClassifier, error) {
	stub := &KNNClassifier{}
	err := stub.Load(filePath)
	if err != nil {
		return nil, err
	}
	return stub, nil
}
511666
func IsRecoverable(e error) bool {
	if re, ok := e.(Recoverable); ok {
		return re.IsRecoverable()
	}
	return false
}
197340
func getClassifier() *bayesian.Classifier {
	// NOTE(tso): this could probably go into an init() function instead
	// but this lazy loading approach works, and it's conceivable that the
	// analyse() function might not invoked in an actual runtime anyway
	if !classifier_initialized {
		data, err := data.Asset("classifier")
		if err != nil {
			log.Panicln(err)
		}
		reader := bytes.NewReader(data)
		classifier, err = bayesian.NewClassifierFromReader(reader)
		if err != nil {
			log.Panicln(err)
		}
		classifier_initialized = true
	}
	return classifier
}
1127228
func (s *CreateXMLClassifierRequest) SetClassification(v string) *CreateXMLClassifierRequest {
	s.Classification = &v
	return s
}
454203
func Detect(code []byte) (string, error) {
	languages := registry.Languages()
	return detect(code, languages, nil)
}
1076381
func (v *View) Classify(point int) (res int) {
	var a, b string = "", ""
	ws := v.Settings().String("word_separators", DEFAULT_SEPARATORS)
	if point > 0 {
		a = v.Substr(text.Region{point - 1, point})
	}
	if point < v.Size() {
		b = v.Substr(text.Region{point, point + 1})
	}

	// Out of range
	if v.Size() == 0 || point < 0 || point > v.Size() {
		res = 3520
		return
	}

	// If before and after the point are separators return 0
	if re, err := rubex.Compile(ws); err != nil {
		log.Error(err)
	} else if a == b && re.MatchString(a) {
		res = 0
		return
	}

	// SubWord start & end
	if re, err := rubex.Compile("[A-Z]"); err != nil {
		log.Error(err)
	} else {
		if re.MatchString(b) && !re.MatchString(a) {
			res |= CLASS_SUB_WORD_START
			res |= CLASS_SUB_WORD_END
		}
	}
	if a == "_" && b != "_" {
		res |= CLASS_SUB_WORD_START
	}
	if b == "_" && a != "_" {
		res |= CLASS_SUB_WORD_END
	}

	// Punc start & end
	if re, err := rubex.Compile(ws); err != nil {
		log.Error(err)
	} else {
		// Why ws != ""? See https://github.com/limetext/rubex/issues/2
		if ((re.MatchString(b) && ws != "") || b == "") && !(re.MatchString(a) && ws != "") {
			res |= CLASS_PUNCTUATION_START
		}
		if ((re.MatchString(a) && ws != "") || a == "") && !(re.MatchString(b) && ws != "") {
			res |= CLASS_PUNCTUATION_END
		}
		// Word start & end
		if re1, err := rubex.Compile("\\w"); err != nil {
			log.Error(err)
		} else if re2, err := rubex.Compile("\\s"); err != nil {
			log.Error(err)
		} else {
			if re1.MatchString(b) && ((re.MatchString(a) && ws != "") || re2.MatchString(a) || a == "") {
				res |= CLASS_WORD_START
			}
			if re1.MatchString(a) && ((re.MatchString(b) && ws != "") || re2.MatchString(b) || b == "") {
				res |= CLASS_WORD_END
			}
		}
	}

	// Line start & end
	if a == "\n" || a == "" {
		res |= CLASS_LINE_START
	}
	if b == "\n" || b == "" {
		res |= CLASS_LINE_END
		if ws == "" {
			res |= CLASS_WORD_END
		}
	}

	// Empty line
	if (a == "\n" && b == "\n") || (a == "" && b == "") {
		res |= CLASS_EMPTY_LINE
	}
	// Middle word
	if re, err := rubex.Compile("\\w"); err != nil {
		log.Error(err)
	} else {
		if re.MatchString(a) && re.MatchString(b) {
			res |= CLASS_MIDDLE_WORD
		}
	}

	// Word start & end with punc
	if re, err := rubex.Compile("\\s"); err != nil {
		log.Error(err)
	} else {
		if (res&CLASS_PUNCTUATION_START != 0) && (re.MatchString(a) || a == "") {
			res |= CLASS_WORD_START_WITH_PUNCTUATION
		}
		if (res&CLASS_PUNCTUATION_END != 0) && (re.MatchString(b) || b == "") {
			res |= CLASS_WORD_END_WITH_PUNCTUATION
		}
	}

	// Openning & closing parentheses
	if re, err := rubex.Compile("[(\\[{]"); err != nil {
		log.Error(err)
	} else {
		if re.MatchString(a) || re.MatchString(b) {
			res |= CLASS_OPENING_PARENTHESIS
		}
	}
	if re, err := rubex.Compile("[)\\]}]"); err != nil {
		log.Error(err)
	} else {
		if re.MatchString(a) || re.MatchString(b) {
			res |= CLASS_CLOSING_PARENTHESIS
		}
	}
	// TODO: isn't this a bug? what's the relation between
	// ',' and parentheses
	if a == "," {
		res |= CLASS_OPENING_PARENTHESIS
	}
	if b == "," {
		res |= CLASS_CLOSING_PARENTHESIS
	}

	return
}
1258624
func RetryableError(err error) *RetryError {
	if err == nil {
		return nil
	}
	return &RetryError{Err: err, Retryable: true}
}