<commit_before>package slinguist

const OtherLanguage = "Other"

var (
	ExtensionsByLanguage map[string][]string
	ignoredExtensions    = map[string]bool{
		".asc": true, ".cgi": true, ".fcgi": true, ".gml": true, ".fx": true,
		".vhost": true,
	}
	auxiliaryLanguages = map[string]bool{
		"Other": true, "XML": true, "YAML": true, "TOML": true, "INI": true,
		"JSON": true, "TeX": true, "Public Key": true, "AsciiDoc": true,
		"AGS Script": true, "VimL": true, "Diff": true, "CMake": true, "fish": true,
		"Awk": true, "Graphviz (DOT)": true, "Markdown": true, "desktop": true,
		"XSLT": true, "SQL": true, "RMarkdown": true, "IRC log": true,
		"reStructuredText": true, "Twig": true, "CSS": true, "Batchfile": true,
		"Text": true, "HTML+ERB": true, "HTML": true, "Gettext Catalog": true,
		"Smarty": true, "Raw token data": true,
	}
)

func init() {
	for l, _ := range ignoredExtensions {
		languagesByExtension[l] = []string{OtherLanguage}
	}

	ExtensionsByLanguage = reverseStringListMap(languagesByExtension)
}

// GetLanguageExtensions returns the different extensions being used by the
// language.
func GetLanguageExtensions(language string) []string {
	return ExtensionsByLanguage[language]
}

// GetLanguage return the Language for a given filename and file content.
func GetLanguage(filename string, content []byte) string {
	if lang, safe := GetLanguageByExtension(filename); safe {
		return lang
	}

	lang, _ := GetLanguageByContent(filename, content)
	return lang
}<commit_msg>GetLanguage follows strategies shebang, extension, content<commit_after>package slinguist

const OtherLanguage = "Other"

var (
	ExtensionsByLanguage map[string][]string
	ignoredExtensions    = map[string]bool{
		".asc": true, ".cgi": true, ".fcgi": true, ".gml": true, ".fx": true,
		".vhost": true,
	}
	auxiliaryLanguages = map[string]bool{
		"Other": true, "XML": true, "YAML": true, "TOML": true, "INI": true,
		"JSON": true, "TeX": true, "Public Key": true, "AsciiDoc": true,
		"AGS Script": true, "VimL": true, "Diff": true, "CMake": true, "fish": true,
		"Awk": true, "Graphviz (DOT)": true, "Markdown": true, "desktop": true,
		"XSLT": true, "SQL": true, "RMarkdown": true, "IRC log": true,
		"reStructuredText": true, "Twig": true, "CSS": true, "Batchfile": true,
		"Text": true, "HTML+ERB": true, "HTML": true, "Gettext Catalog": true,
		"Smarty": true, "Raw token data": true,
	}
)

func init() {
	for l, _ := range ignoredExtensions {
		languagesByExtension[l] = []string{OtherLanguage}
	}

	ExtensionsByLanguage = reverseStringListMap(languagesByExtension)
}

// GetLanguageExtensions returns the different extensions being used by the
// language.
func GetLanguageExtensions(language string) []string {
	return ExtensionsByLanguage[language]
}

// GetLanguage return the Language for a given filename and file content.
func GetLanguage(filename string, content []byte) string {
	if lang, safe := GetLanguageByShebang(content); safe {
		return lang
	}

	if lang, safe := GetLanguageByExtension(filename); safe {
		return lang
	}

	lang, _ := GetLanguageByContent(filename, content)
	return lang
}
{'fraction_non_alphanumeric': 0.1574701516618264, 'fraction_numerical': 0.0, 'mean_word_length': 5.262626262626263, 'pattern_counts': {'":': 76, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7091350', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1018, 'n_words': 312}