mirror of
https://github.com/KevinMidboe/linguist.git
synced 2026-01-01 15:06:16 +00:00
Kicking the tyres
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
module Linguist
|
module Linguist
|
||||||
# A collection of simple heuristics that can be used to better analyze languages.
|
# A collection of simple heuristics that can be used to better analyze languages.
|
||||||
class Heuristics
|
class Heuristics
|
||||||
ACTIVE = false
|
ACTIVE = true
|
||||||
|
|
||||||
# Public: Given an array of String language names,
|
# Public: Given an array of String language names,
|
||||||
# apply heuristics against the given data and return an array
|
# apply heuristics against the given data and return an array
|
||||||
@@ -12,26 +12,28 @@ module Linguist
|
|||||||
#
|
#
|
||||||
# Returns an array of Languages or []
|
# Returns an array of Languages or []
|
||||||
def self.find_by_heuristics(data, languages)
|
def self.find_by_heuristics(data, languages)
|
||||||
|
determined = nil
|
||||||
if active?
|
if active?
|
||||||
if languages.all? { |l| ["Objective-C", "C++"].include?(l) }
|
if languages.all? { |l| ["Objective-C", "C++", "C"].include?(l) }
|
||||||
disambiguate_c(data, languages)
|
determined = disambiguate_c(data, languages)
|
||||||
end
|
end
|
||||||
if languages.all? { |l| ["Perl", "Prolog"].include?(l) }
|
if languages.all? { |l| ["Perl", "Prolog"].include?(l) }
|
||||||
disambiguate_pl(data, languages)
|
determined = disambiguate_pl(data, languages)
|
||||||
end
|
end
|
||||||
if languages.all? { |l| ["ECL", "Prolog"].include?(l) }
|
if languages.all? { |l| ["ECL", "Prolog"].include?(l) }
|
||||||
disambiguate_ecl(data, languages)
|
determined = disambiguate_ecl(data, languages)
|
||||||
end
|
end
|
||||||
if languages.all? { |l| ["TypeScript", "XML"].include?(l) }
|
if languages.all? { |l| ["TypeScript", "XML"].include?(l) }
|
||||||
disambiguate_ts(data, languages)
|
determined = disambiguate_ts(data, languages)
|
||||||
end
|
end
|
||||||
if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) }
|
if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) }
|
||||||
disambiguate_cl(data, languages)
|
determined = disambiguate_cl(data, languages)
|
||||||
end
|
end
|
||||||
if languages.all? { |l| ["Rebol", "R"].include?(l) }
|
if languages.all? { |l| ["Rebol", "R"].include?(l) }
|
||||||
disambiguate_r(data, languages)
|
determined = disambiguate_r(data, languages)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
determined
|
||||||
end
|
end
|
||||||
|
|
||||||
# .h extensions are ambigious between C, C++, and Objective-C.
|
# .h extensions are ambigious between C, C++, and Objective-C.
|
||||||
|
|||||||
Reference in New Issue
Block a user