mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Heuristics for Common Lisp and NewLisp
This commit is contained in:
@@ -25,6 +25,9 @@ module Linguist
|
||||
if languages.all? { |l| ["TypeScript", "XML"].include?(l) }
|
||||
disambiguate_ts(data, languages)
|
||||
end
|
||||
if languages.all? { |l| ["Common Lisp", "NewLisp"].include?(l) }
|
||||
disambiguate_lsp(data, languages)
|
||||
end
|
||||
if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) }
|
||||
disambiguate_cl(data, languages)
|
||||
end
|
||||
@@ -69,6 +72,13 @@ module Linguist
|
||||
matches
|
||||
end
|
||||
|
||||
def self.disambiguate_lsp(data, languages)
|
||||
matches = []
|
||||
matches << Language["Common Lisp"] if data.include?("(defun")
|
||||
matches << Language["NewLisp"] if data.include?("true")
|
||||
matches
|
||||
end
|
||||
|
||||
def self.disambiguate_cl(data, languages)
|
||||
matches = []
|
||||
matches << Language["Common Lisp"] if data.include?("(defun ")
|
||||
|
||||
@@ -75,6 +75,18 @@ class TestHeuristcs < Test::Unit::TestCase
|
||||
assert_equal Language["XML"], results.first
|
||||
end
|
||||
|
||||
def test_lsp_commonlisp_by_heuristics
|
||||
languages = ["Common Lisp", "NewLisp"]
|
||||
results = Heuristics.disambiguate_lsp(fixture("Common Lisp/sample.lsp"), languages)
|
||||
assert_equal Language["Common Lisp"], results.first
|
||||
end
|
||||
|
||||
def test_lsp_newlisp_by_heuristics
|
||||
languages = ["Common Lisp", "NewLisp"]
|
||||
results = Heuristics.disambiguate_lsp(fixture("NewLisp/irc.lsp"), languages)
|
||||
assert_equal Language["NewLisp"], results.first
|
||||
end
|
||||
|
||||
def test_cl_by_heuristics
|
||||
languages = ["Common Lisp", "OpenCL"]
|
||||
languages.each do |language|
|
||||
|
||||
Reference in New Issue
Block a user