From a2c00f9ed450ef0f544687dc289a1f77fea72db0 Mon Sep 17 00:00:00 2001 From: Nick Walker Date: Sat, 4 Jan 2025 05:53:41 +0000 Subject: [PATCH] Add heuristic for Linear Programming Linear programs must have an objective --- lib/linguist/heuristics.yml | 5 +++++ test/test_heuristics.rb | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/lib/linguist/heuristics.yml b/lib/linguist/heuristics.yml index 923303e6d..e564e9397 100644 --- a/lib/linguist/heuristics.yml +++ b/lib/linguist/heuristics.yml @@ -417,6 +417,11 @@ disambiguations: pattern: '^import [a-z]' - language: Lean 4 pattern: '^import [A-Z]' +- extensions: ['.lp'] + rules: + - language: Linear Programming + pattern: '^(End|end|END|Minimize|Maximize)$' + - language: Answer Set Programming - extensions: ['.ls'] rules: - language: LoomScript diff --git a/test/test_heuristics.rb b/test/test_heuristics.rb index ed2800210..fd69b0060 100755 --- a/test/test_heuristics.rb +++ b/test/test_heuristics.rb @@ -615,6 +615,13 @@ def test_lisp_by_heuristics }, "main.lisp") end + def test_lp_by_heuristics + assert_heuristics({ + "Answer Set Programming" => all_fixtures("Answer Set Programming", "*.lp"), + "Linear Programming" => all_fixtures("Linear Programming", "*.lp") + }) + end + def test_ls_by_heuristics assert_heuristics({ "LiveScript" => all_fixtures("LiveScript", "*.ls"),