mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
docs
This commit is contained in:
@@ -6,7 +6,7 @@ module Linguist
|
||||
# Public: Use the classifier to detect language of the blob.
|
||||
#
|
||||
# blob - An object that quacks like a blob.
|
||||
# possible_languages - Array of
|
||||
# possible_languages - Array of Language objects
|
||||
#
|
||||
# Examples
|
||||
#
|
||||
@@ -14,7 +14,7 @@ module Linguist
|
||||
# Language["Ruby"], Language["Python"]
|
||||
# ])
|
||||
#
|
||||
# Returns an Array of possible lanuages, most probable first.
|
||||
# Returns an Array of Language objects, most probable first.
|
||||
def self.call(blob, possible_languages)
|
||||
language_names = possible_languages.map(&:name)
|
||||
classify(Samples.cache, blob.data, language_names).map do |name, _|
|
||||
|
||||
@@ -3,6 +3,19 @@ module Linguist
|
||||
class Heuristics
|
||||
ACTIVE = true
|
||||
|
||||
# Public: Use heuristics to detect language of the blob.
|
||||
#
|
||||
# blob - An object that quacks like a blob.
|
||||
# possible_languages - Array of Language objects
|
||||
#
|
||||
# Examples
|
||||
#
|
||||
# Heuristics.call(FileBlob.new("path/to/file"), [
|
||||
# Language["Ruby"], Language["Python"]
|
||||
# ])
|
||||
#
|
||||
# Returns an Array with one Language if a heuristic matched, or empty if
|
||||
# none matched or were inconclusive.
|
||||
def self.call(blob, languages)
|
||||
find_by_heuristics(blob.data, languages.map(&:name))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user