mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-08 04:18:48 +00:00
Merge branch 'master' into cache-bustin
Conflicts: lib/linguist/version.rb
This commit is contained in:
@@ -165,7 +165,7 @@ If you are the current maintainer of this gem:
|
|||||||
0. Ensure that tests are green: `bundle exec rake test`
|
0. Ensure that tests are green: `bundle exec rake test`
|
||||||
0. Bump gem version in `lib/linguist/version.rb`. For example, [like this](https://github.com/github/linguist/commit/8d2ea90a5ba3b2fe6e1508b7155aa4632eea2985).
|
0. Bump gem version in `lib/linguist/version.rb`. For example, [like this](https://github.com/github/linguist/commit/8d2ea90a5ba3b2fe6e1508b7155aa4632eea2985).
|
||||||
0. Make a PR to github/linguist. For example, [#1238](https://github.com/github/linguist/pull/1238).
|
0. Make a PR to github/linguist. For example, [#1238](https://github.com/github/linguist/pull/1238).
|
||||||
0. Build a local gem: `gem build github-linguist.gemspec`
|
0. Build a local gem: `bundle exec rake build_gem`
|
||||||
0. Testing:
|
0. Testing:
|
||||||
0. Bump the Gemfile and Gemfile.lock versions for an app which relies on this gem
|
0. Bump the Gemfile and Gemfile.lock versions for an app which relies on this gem
|
||||||
0. Install the new gem locally
|
0. Install the new gem locally
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ module Linguist
|
|||||||
if languages.all? { |l| ["ECL", "Prolog"].include?(l) }
|
if languages.all? { |l| ["ECL", "Prolog"].include?(l) }
|
||||||
result = disambiguate_ecl(data, languages)
|
result = disambiguate_ecl(data, languages)
|
||||||
end
|
end
|
||||||
|
if languages.all? { |l| ["IDL", "Prolog"].include?(l) }
|
||||||
|
result = disambiguate_pro(data, languages)
|
||||||
|
end
|
||||||
if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) }
|
if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) }
|
||||||
result = disambiguate_cl(data, languages)
|
result = disambiguate_cl(data, languages)
|
||||||
end
|
end
|
||||||
@@ -51,6 +54,16 @@ module Linguist
|
|||||||
matches
|
matches
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.disambiguate_pro(data, languages)
|
||||||
|
matches = []
|
||||||
|
if (data.include?(":-"))
|
||||||
|
matches << Language["Prolog"]
|
||||||
|
else
|
||||||
|
matches << Language["IDL"]
|
||||||
|
end
|
||||||
|
matches
|
||||||
|
end
|
||||||
|
|
||||||
def self.disambiguate_ts(data, languages)
|
def self.disambiguate_ts(data, languages)
|
||||||
matches = []
|
matches = []
|
||||||
if (data.include?("</translation>"))
|
if (data.include?("</translation>"))
|
||||||
|
|||||||
@@ -949,6 +949,7 @@ HTML:
|
|||||||
|
|
||||||
HTML+Django:
|
HTML+Django:
|
||||||
type: markup
|
type: markup
|
||||||
|
tm_scope: text.html.django
|
||||||
group: HTML
|
group: HTML
|
||||||
lexer: HTML+Django/Jinja
|
lexer: HTML+Django/Jinja
|
||||||
extensions:
|
extensions:
|
||||||
@@ -957,6 +958,7 @@ HTML+Django:
|
|||||||
|
|
||||||
HTML+ERB:
|
HTML+ERB:
|
||||||
type: markup
|
type: markup
|
||||||
|
tm_scope: text.html.erb
|
||||||
group: HTML
|
group: HTML
|
||||||
lexer: RHTML
|
lexer: RHTML
|
||||||
aliases:
|
aliases:
|
||||||
@@ -967,6 +969,7 @@ HTML+ERB:
|
|||||||
|
|
||||||
HTML+PHP:
|
HTML+PHP:
|
||||||
type: markup
|
type: markup
|
||||||
|
tm_scope: text.html.php
|
||||||
group: HTML
|
group: HTML
|
||||||
extensions:
|
extensions:
|
||||||
- .phtml
|
- .phtml
|
||||||
@@ -1102,6 +1105,7 @@ J:
|
|||||||
|
|
||||||
JSON:
|
JSON:
|
||||||
type: data
|
type: data
|
||||||
|
tm_scope: source.json
|
||||||
group: JavaScript
|
group: JavaScript
|
||||||
ace_mode: json
|
ace_mode: json
|
||||||
searchable: false
|
searchable: false
|
||||||
@@ -1293,6 +1297,7 @@ Literate Agda:
|
|||||||
|
|
||||||
Literate CoffeeScript:
|
Literate CoffeeScript:
|
||||||
type: programming
|
type: programming
|
||||||
|
tm_scope: source.litcoffee
|
||||||
group: CoffeeScript
|
group: CoffeeScript
|
||||||
lexer: Text only
|
lexer: Text only
|
||||||
ace_mode: markdown
|
ace_mode: markdown
|
||||||
@@ -1587,6 +1592,7 @@ Objective-C:
|
|||||||
|
|
||||||
Objective-C++:
|
Objective-C++:
|
||||||
type: programming
|
type: programming
|
||||||
|
tm_scope: source.objc++
|
||||||
color: "#4886FC"
|
color: "#4886FC"
|
||||||
aliases:
|
aliases:
|
||||||
- obj-c++
|
- obj-c++
|
||||||
@@ -1829,6 +1835,7 @@ Prolog:
|
|||||||
extensions:
|
extensions:
|
||||||
- .pl
|
- .pl
|
||||||
- .ecl
|
- .ecl
|
||||||
|
- .pro
|
||||||
- .prolog
|
- .prolog
|
||||||
|
|
||||||
Propeller Spin:
|
Propeller Spin:
|
||||||
@@ -2083,6 +2090,7 @@ SAS:
|
|||||||
|
|
||||||
SCSS:
|
SCSS:
|
||||||
type: markup
|
type: markup
|
||||||
|
tm_scope: source.scss
|
||||||
group: CSS
|
group: CSS
|
||||||
ace_mode: scss
|
ace_mode: scss
|
||||||
extensions:
|
extensions:
|
||||||
@@ -2123,6 +2131,7 @@ Sage:
|
|||||||
|
|
||||||
Sass:
|
Sass:
|
||||||
type: markup
|
type: markup
|
||||||
|
tm_scope: source.sass
|
||||||
group: CSS
|
group: CSS
|
||||||
extensions:
|
extensions:
|
||||||
- .sass
|
- .sass
|
||||||
@@ -2597,6 +2606,7 @@ Xtend:
|
|||||||
|
|
||||||
YAML:
|
YAML:
|
||||||
type: data
|
type: data
|
||||||
|
tm_scope: source.yaml
|
||||||
aliases:
|
aliases:
|
||||||
- yml
|
- yml
|
||||||
extensions:
|
extensions:
|
||||||
|
|||||||
68
samples/Prolog/logic-problem.pro
Normal file
68
samples/Prolog/logic-problem.pro
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/**
|
||||||
|
* Question 1.1
|
||||||
|
* combiner(+Buddies, -Pairs)
|
||||||
|
*/
|
||||||
|
combiner([], []).
|
||||||
|
combiner([First|Buddies], Pairs):-
|
||||||
|
make_pairs(First, Buddies, Pairs1),
|
||||||
|
combiner(Buddies, Pairs2),
|
||||||
|
concat(Pairs1, Pairs2, Pairs).
|
||||||
|
|
||||||
|
/**
|
||||||
|
* make_pairs(+Buddy, +Buddies, -Pairs)
|
||||||
|
*/
|
||||||
|
make_pairs(Buddy, [], []).
|
||||||
|
make_pairs(Buddy, [First|Buddies], [(Buddy, First)|Pairs]):-
|
||||||
|
make_pairs(Buddy, Buddies, Pairs).
|
||||||
|
|
||||||
|
/**
|
||||||
|
* concat(+X, +Y, ?T)
|
||||||
|
*/
|
||||||
|
concat([], Y, Y).
|
||||||
|
concat([P|R], Y, [P|T]):-
|
||||||
|
concat(R, Y, T).
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Question 1.2
|
||||||
|
* extraire(+AllPossiblePairs, +NbPairs, -Tp, -RemainingPairs)
|
||||||
|
*/
|
||||||
|
extraire(AllPossiblePairs, 0, [], AllPossiblePairs).
|
||||||
|
extraire([PossiblePair|AllPossiblePairs], NbPairs, [PossiblePair|Tp], NewRemainingPairs):-
|
||||||
|
NbPairs > 0,
|
||||||
|
NewNbPairs is NbPairs - 1,
|
||||||
|
extraire(AllPossiblePairs, NewNbPairs, Tp, RemainingPairs),
|
||||||
|
not(pair_in_array(PossiblePair, Tp)),
|
||||||
|
delete_pair(RemainingPairs, PossiblePair, NewRemainingPairs).
|
||||||
|
extraire([PossiblePair|AllPossiblePairs], NbPairs, Tp, [PossiblePair|RemainingPairs]):-
|
||||||
|
NbPairs > 0,
|
||||||
|
extraire(AllPossiblePairs, NbPairs, Tp, RemainingPairs),
|
||||||
|
pair_in_array(PossiblePair, Tp).
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete_pair(+Pairs, +Pair, -PairsWithoutPair)
|
||||||
|
*/
|
||||||
|
delete_pair([], _, []).
|
||||||
|
delete_pair([Pair|Pairs], Pair, Pairs):-!.
|
||||||
|
delete_pair([FirstPair|Pairs], Pair, [FirstPair|PairsWithoutPair]):-
|
||||||
|
delete_pair(Pairs, Pair, PairsWithoutPair).
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pair_in_array(+Pair, +Pairs)
|
||||||
|
*/
|
||||||
|
pair_in_array((A, B), [(C, D)|Pairs]):-
|
||||||
|
(A == C ; B == D ; A == D ; B == C),
|
||||||
|
!.
|
||||||
|
pair_in_array(Pair, [FirstPair|Pairs]):-
|
||||||
|
pair_in_array(Pair, Pairs).
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Question 1.3
|
||||||
|
* les_tps(+Buddies, -Tps)
|
||||||
|
*/
|
||||||
|
les_tps(Buddies, Tps):-
|
||||||
|
combiner(Buddies, PossiblePairs),
|
||||||
|
length(Buddies, NbBuddies),
|
||||||
|
NbPairs is integer(NbBuddies / 2),
|
||||||
|
findall(Tp, extraire(PossiblePairs, NbPairs, Tp, _), Tps).
|
||||||
@@ -65,6 +65,18 @@ class TestHeuristcs < Test::Unit::TestCase
|
|||||||
assert_equal Language["ECL"], results.first
|
assert_equal Language["ECL"], results.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_pro_prolog_by_heuristics
|
||||||
|
languages = ["IDL", "Prolog"]
|
||||||
|
results = Heuristics.disambiguate_pro(fixture("Prolog/logic-problem.pro"), languages)
|
||||||
|
assert_equal Language["Prolog"], results.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_pro_idl_by_heuristics
|
||||||
|
languages = ["IDL", "Prolog"]
|
||||||
|
results = Heuristics.disambiguate_pro(fixture("IDL/mg_acosh.pro"), languages)
|
||||||
|
assert_equal Language["IDL"], results.first
|
||||||
|
end
|
||||||
|
|
||||||
def test_ts_typescript_by_heuristics
|
def test_ts_typescript_by_heuristics
|
||||||
languages = ["TypeScript", "XML"]
|
languages = ["TypeScript", "XML"]
|
||||||
results = Heuristics.disambiguate_ts(fixture("TypeScript/classes.ts"), languages)
|
results = Heuristics.disambiguate_ts(fixture("TypeScript/classes.ts"), languages)
|
||||||
|
|||||||
Reference in New Issue
Block a user