mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-29 21:31:01 +00:00
Adding Perl heuristic (and fixing up Prolog)
This commit is contained in:
@@ -33,9 +33,10 @@ module Linguist
|
|||||||
matches
|
matches
|
||||||
end
|
end
|
||||||
|
|
||||||
def self_disambiguate_pl(data, languages)
|
def self.disambiguate_pl(data, languages)
|
||||||
matches = []
|
matches = []
|
||||||
matches << Language["Prolog"] if data.include?(":-")
|
matches << Language["Prolog"] if data.include?(":-")
|
||||||
|
matches << Language["Perl"] if data.include?("use strict")
|
||||||
matches
|
matches
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -38,4 +38,16 @@ class TestHeuristcs < Test::Unit::TestCase
|
|||||||
match = Language.detect("Hello.m", fixture("Objective-C/hello.m"))
|
match = Language.detect("Hello.m", fixture("Objective-C/hello.m"))
|
||||||
assert_equal Language["Objective-C"], match
|
assert_equal Language["Objective-C"], match
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_pl_prolog_by_heuristics
|
||||||
|
languages = ["Perl", "Prolog"]
|
||||||
|
results = Heuristics.disambiguate_pl(fixture("Prolog/turing.pl"), languages)
|
||||||
|
assert_equal Language["Prolog"], results.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_pl_perl_by_heuristics
|
||||||
|
languages = ["Perl", "Prolog"]
|
||||||
|
results = Heuristics.disambiguate_pl(fixture("Perl/perl-test.t"), languages)
|
||||||
|
assert_equal Language["Perl"], results.first
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user