Merge pull request #1503 from github/prolog-pl-samples

Prolog pl samples
This commit is contained in:
Arfon Smith
2014-09-04 16:10:39 -05:00
5 changed files with 1463 additions and 88 deletions

View File

@@ -1,7 +1,7 @@
module Linguist
# A collection of simple heuristics that can be used to better analyze languages.
class Heuristics
ACTIVE = false
ACTIVE = true
# Public: Given an array of String language names,
# apply heuristics against the given data and return an array
@@ -13,24 +13,13 @@ module Linguist
# Returns an array of Languages or []
def self.find_by_heuristics(data, languages)
if active?
if languages.all? { |l| ["Objective-C", "C++"].include?(l) }
disambiguate_c(data, languages)
end
if languages.all? { |l| ["Perl", "Prolog"].include?(l) }
disambiguate_pl(data, languages)
result = disambiguate_pl(data, languages)
end
if languages.all? { |l| ["ECL", "Prolog"].include?(l) }
disambiguate_ecl(data, languages)
end
if languages.all? { |l| ["TypeScript", "XML"].include?(l) }
disambiguate_ts(data, languages)
end
if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) }
disambiguate_cl(data, languages)
end
if languages.all? { |l| ["Rebol", "R"].include?(l) }
disambiguate_r(data, languages)
result = disambiguate_ecl(data, languages)
end
return result
end
end

View File

@@ -136,7 +136,7 @@ module Linguist
elsif (determined = Heuristics.find_by_heuristics(data, possible_language_names)) && !determined.empty?
determined.first
# Lastly, fall back to the probablistic classifier.
elsif classified = Classifier.classify(Samples::DATA, data, possible_language_names ).first
elsif classified = Classifier.classify(Samples::DATA, data, possible_language_names).first
# Return the actual Language object based of the string language name (i.e., first element of `#classify`)
Language[classified[0]]
end

View File

@@ -1212,7 +1212,7 @@ LSL:
interpreters:
- lsl
color: '#3d9970'
LabVIEW:
type: programming
lexer: Text only
@@ -1794,9 +1794,9 @@ Prolog:
type: programming
color: "#74283c"
extensions:
- .prolog
- .ecl
- .pl
- .ecl
- .prolog
Propeller Spin:
type: programming

View File

@@ -851,8 +851,8 @@
"exception.zep.php"
]
},
"tokens_total": 654867,
"languages_total": 904,
"tokens_total": 659332,
"languages_total": 905,
"tokens": {
"ABAP": {
"*/**": 1,
@@ -55996,61 +55996,441 @@
"TWO_PI": 1
},
"Prolog": {
"%": 72,
"-": 350,
"module": 4,
"(": 1161,
"cpa_admin": 1,
"[": 290,
"change_password_form//1": 1,
"]": 288,
")": 1158,
".": 232,
"use_module": 20,
"user": 45,
"user_db": 1,
"library": 19,
"http/http_parameters": 1,
"http/http_session": 1,
"http/html_write": 1,
"http/html_head": 1,
"http/mimetype": 1,
"http/http_dispatch": 1,
"url": 1,
"debug": 5,
"lists": 1,
"option": 8,
"http_settings": 1,
"http_handler": 20,
"cliopatria": 38,
"list_users": 13,
"create_admin": 3,
"add_user_form": 4,
"add_openid_server_form": 4,
"add_user": 6,
"self_register": 4,
"add_openid_server": 3,
"edit_user_form": 7,
"edit_user": 4,
"del_user": 5,
"edit_openid_server_form": 6,
"edit_openid_server": 4,
"del_openid_server": 4,
"change_password_form": 7,
"change_password": 5,
"login_form": 4,
"user_login": 4,
"user_logout": 4,
"settings": 4,
"save_settings": 3,
"%": 194,
"+": 47,
"Request": 46,
"HTTP": 4,
"Handler": 1,
"listing": 1,
"registered": 3,
"users.": 2,
"_Request": 11,
"authorized": 13,
"admin": 31,
"if_allowed": 4,
"edit": 15,
"true": 32,
"UserOptions": 5,
"openid": 5,
"OpenIDOptions": 2,
"reply_html_page": 15,
"default": 16,
"title": 13,
"h1": 15,
"user_table": 3,
"p": 11,
"action": 18,
"location_by_id": 13,
"openid_server_table": 4,
"Token": 2,
"Options": 43,
"logged_on": 4,
"User": 77,
"anonymous": 2,
"catch": 2,
"check_permission": 1,
"_": 62,
"fail": 3,
"//": 7,
"HTML": 4,
"component": 3,
"generating": 1,
"a": 25,
"table": 9,
"of": 10,
"{": 22,
"setof": 3,
"U": 2,
"current_user": 6,
"Users": 2,
"}": 22,
"html": 25,
"class": 14,
"block": 2,
"tr": 16,
"th": 12,
"|": 44,
"T": 4,
"user_property": 8,
"realname": 18,
"Name": 19,
"findall": 1,
"Idle": 6,
"Login": 9,
"connection": 1,
"Pairs0": 2,
"keysort": 1,
"Pairs": 4,
"OnLine": 4,
";": 37,
"length": 9,
"N": 7,
"online": 3,
"td": 20,
"on_since": 3,
"idle": 3,
"edit_user_button": 3,
"href": 6,
"encode": 4,
"_Idle": 1,
"_Connections": 2,
"format_time": 1,
"string": 10,
"Date": 2,
"_Login": 1,
"mmss_duration": 2,
"String": 10,
"Time": 3,
"in": 1,
"seconds": 1,
"Secs": 4,
"is": 24,
"round": 1,
"Hour": 2,
"Min": 4,
"mod": 2,
"Sec": 2,
"format": 9,
"Create": 2,
"the": 14,
"administrator": 1,
"login.": 2,
"throw": 12,
"error": 13,
"permission_error": 4,
"create": 3,
"context": 3,
"align": 16,
"center": 6,
"new_user_form": 3,
"real_name": 2,
"Form": 3,
"to": 19,
"register": 3,
"user.": 2,
"value": 11,
"PermUser": 3,
"form": 14,
"method": 6,
"input": 25,
"pwd1": 5,
"type": 16,
"password": 21,
"pwd2": 5,
"permissions": 5,
"buttons": 5,
"colspan": 6,
"right": 11,
"submit": 6,
"Label": 10,
"name": 8,
"size": 5,
"Only": 1,
"provide": 1,
"field": 4,
"if": 4,
"this": 1,
"not": 1,
"already": 2,
"given.": 1,
"This": 2,
"because": 1,
"firefox": 1,
"determines": 1,
"login": 3,
"from": 3,
"text": 6,
"immediately": 1,
"above": 1,
"entry.": 1,
"Other": 1,
"browsers": 1,
"may": 1,
"do": 1,
"it": 1,
"different": 1,
"so": 1,
"only": 2,
"having": 1,
"one": 1,
"probably": 1,
"savest": 1,
"solution.": 1,
"RealName": 13,
"hidden": 7,
"_Options": 1,
"API": 1,
"new": 6,
"The": 3,
"current": 3,
"must": 3,
"have": 1,
"administrative": 2,
"rights": 2,
"or": 3,
"database": 1,
"be": 6,
"empty.": 1,
"FirstUser": 2,
"http_parameters": 10,
"Password": 13,
"Retype": 4,
"read": 13,
"Read": 12,
"write": 11,
"Write": 12,
"Admin": 12,
"attribute_declarations": 10,
"attribute_decl": 21,
"password_mismatch": 2,
"password_hash": 3,
"Hash": 6,
"phrase": 6,
"allow": 17,
"Allow": 11,
"user_add": 3,
"reply_login": 5,
"Self": 1,
"and": 6,
"enable_self_register": 3,
"set": 2,
"true.": 1,
"limited": 1,
"annotate": 2,
"access.": 1,
"Returns": 1,
"forbidden": 3,
"false": 5,
"exists": 1,
"http_location_by_id": 1,
"MyUrl": 3,
"setting": 1,
"http_reply": 3,
"properties": 3,
"User.": 1,
"b": 6,
"i": 1,
"Term": 16,
"..": 11,
"Value": 15,
"O2": 6,
"p_name": 2,
"permission_checkbox": 4,
"Actions": 3,
"openid_server_property": 3,
"pterm": 5,
"Action": 17,
"memberchk": 4,
"Opts": 4,
"checked": 2,
"def_user_permissions": 3,
"DefPermissions": 2,
"checkbox": 1,
"Handle": 3,
"reply": 3,
"form.": 2,
"optional": 6,
"description": 18,
"modify_user": 2,
"modify_permissions": 2,
"Property": 6,
"_Name": 2,
"var": 7,
"set_user_property": 3,
"Access": 2,
"on": 2,
"_Access": 1,
"off": 5,
"_Repositiory": 2,
"_Action": 3,
"Delete": 2,
"delete": 2,
"user_del": 1,
"change": 2,
"context_error": 2,
"not_logged_in": 2,
"UserID": 1,
"that": 2,
"shows": 1,
"for": 4,
"changing": 1,
"UserID.": 1,
"id": 3,
"user_or_old": 3,
"pwd0": 2,
"handler": 2,
"password.": 1,
"logged": 1,
"on.": 1,
"New": 3,
"existence_error": 1,
"validate_password": 2,
"presents": 1,
"If": 2,
"there": 1,
"parameter": 2,
"return_to": 3,
"openid.return_to": 1,
"using": 1,
"redirect": 1,
"given": 2,
"URL.": 1,
"Otherwise": 1,
"display": 1,
"welcome": 1,
"page.": 1,
"ReturnTo": 6,
"Extra": 3,
"moved_temporary": 1,
"Logout": 1,
"logout": 1,
"Param": 1,
"DeclObtions": 1,
"semidet.": 4,
"Provide": 1,
"reusable": 1,
"declarations": 1,
"calls": 2,
"http_parameters/3.": 1,
"openid_server": 9,
"bool": 4,
"Def": 2,
"oneof": 1,
"Return": 1,
"an": 3,
"page": 1,
"add": 2,
"OpenID": 4,
"server.": 1,
"new_openid_form": 2,
"new_openid_form//": 1,
"det.": 5,
"Present": 1,
"provider.": 1,
"openid_description": 1,
"code": 2,
"canonical_url": 1,
"URL0": 2,
"URL": 4,
"parse_url": 2,
"Parts": 2,
"Server": 30,
"openid_property": 2,
"List": 1,
"servers": 1,
"S": 2,
"openid_current_server": 1,
"Servers": 2,
"openid_list_servers": 4,
"H": 2,
"openid_list_server": 2,
"openid_field": 3,
"edit_openid_button": 3,
"Field": 2,
"server": 1,
"Description": 2,
"modify_openid": 2,
"openid_modify_permissions": 2,
"openid_set_property": 2,
"openid_del_server": 1,
"Show": 1,
"settings.": 3,
"has": 1,
"editing": 1,
"edit_settings": 2,
"Edit": 4,
"http_show_settings": 1,
"hide_module": 1,
"warn_no_edit": 3,
"settings_no_edit": 1,
"Save": 1,
"modified": 1,
"http_apply_settings": 1,
"save": 1,
"with": 3,
"br": 1,
"subset": 2,
"(": 332,
"Set": 4,
"Subset": 6,
")": 331,
"-": 163,
"append": 3,
"L1": 1,
".": 109,
"powerset": 1,
"bagof": 1,
"module": 3,
"format_spec": 12,
"[": 87,
"format_error/2": 1,
"format_spec/2": 1,
"format_spec//1": 1,
"spec_arity/2": 1,
"spec_types/2": 1,
"]": 87,
"use_module": 8,
"library": 8,
"dcg/basics": 1,
"eos//0": 1,
"integer//1": 1,
"string_without//2": 1,
"error": 6,
"when": 3,
"when/2": 1,
"mavis": 1,
"format_error": 8,
"+": 14,
"Goal": 29,
"Error": 25,
"string": 8,
"is": 12,
"nondet.": 1,
"format": 8,
"Format": 23,
"Args": 19,
"format_error_": 5,
"_": 30,
"debug": 4,
"Spec": 10,
"is_list": 1,
"spec_types": 8,
"Types": 16,
"types_error": 3,
"length": 4,
"TypesLen": 3,
"ArgsLen": 3,
"types_error_": 4,
"Arg": 6,
"|": 25,
"Type": 3,
"ground": 5,
"is_of_type": 2,
@@ -56065,13 +56445,9 @@
"format_fail/3.": 1,
"prolog_walk_code": 1,
"module_class": 1,
"user": 5,
"infer_meta_predicates": 1,
"false": 2,
"autoload": 1,
"format/": 1,
"{": 7,
"}": 7,
"are": 3,
"always": 1,
"loaded": 1,
@@ -56092,7 +56468,6 @@
"checker.": 1,
"succeed": 2,
"even": 1,
"if": 1,
"no": 1,
"found": 1,
"Module": 4,
@@ -56100,12 +56475,10 @@
"predicate_property": 1,
"imported_from": 1,
"Source": 2,
"memberchk": 2,
"system": 1,
"prolog_debug": 1,
"can_check": 2,
"assert": 2,
"to": 5,
"avoid": 1,
"printing": 1,
"goals": 1,
@@ -56114,32 +56487,22 @@
"prolog": 2,
"message": 1,
"message_location": 1,
"//": 1,
"eos.": 1,
"escape": 2,
"Numeric": 4,
"Modifier": 2,
"Action": 15,
"Rest": 12,
"numeric_argument": 5,
"modifier_argument": 3,
"action": 6,
"text": 4,
"String": 6,
";": 12,
"Codes": 21,
"string_codes": 4,
"string_without": 1,
"list": 4,
"semidet.": 3,
"text_codes": 6,
"phrase": 3,
"spec_arity": 2,
"FormatSpec": 2,
"Arity": 3,
"positive_integer": 1,
"det.": 4,
"type": 2,
"Item": 2,
"Items": 2,
"item_types": 3,
@@ -56154,17 +56517,14 @@
"Text": 1,
"codes": 5,
"Var": 5,
"var": 4,
"Atom": 3,
"atom": 6,
"N": 5,
"integer": 7,
"C": 5,
"colon": 1,
"no_colon": 1,
"is_action": 4,
"multi.": 1,
"a": 4,
"d": 3,
"e": 1,
"float": 3,
@@ -56172,7 +56532,6 @@
"G": 2,
"I": 1,
"n": 1,
"p": 1,
"any": 3,
"r": 1,
"s": 2,
@@ -56181,7 +56540,6 @@
"func": 13,
"op": 2,
"xfy": 2,
"of": 8,
"/2": 3,
"list_util": 1,
"xfy_list/3": 1,
@@ -56195,7 +56553,6 @@
"at": 3,
"compile": 3,
"time": 3,
"for": 1,
"macro": 1,
"expansion.": 1,
"compile_function/4.": 1,
@@ -56206,19 +56563,14 @@
"evaluable/1": 1,
"throws": 1,
"exception": 1,
"with": 2,
"strings": 1,
"evaluable": 1,
"term_variables": 1,
"F": 26,
"function_composition_term": 2,
"Functor": 8,
"true": 5,
"..": 6,
"format_template": 7,
"has_type": 2,
"fail": 1,
"be": 4,
"explicit": 1,
"Dict": 3,
"is_dict": 1,
@@ -56226,7 +56578,6 @@
"Function": 5,
"Argument": 1,
"Apply": 1,
"an": 1,
"Argument.": 1,
"A": 1,
"predicate": 4,
@@ -56235,18 +56586,15 @@
"argument": 2,
"generates": 1,
"output": 1,
"and": 2,
"penultimate": 1,
"accepts": 1,
"input.": 1,
"This": 1,
"realized": 1,
"by": 2,
"expanding": 1,
"function": 2,
"application": 2,
"chained": 1,
"calls": 1,
"time.": 1,
"itself": 1,
"can": 3,
@@ -56255,12 +56603,8 @@
"reverse": 4,
"sort": 2,
"c": 2,
"b": 4,
"meta_predicate": 2,
"throw": 1,
"permission_error": 1,
"call": 4,
"context": 1,
"X": 10,
"Y": 7,
"defer": 1,
@@ -56268,13 +56612,10 @@
"run": 1,
"P": 2,
"Creates": 1,
"new": 2,
"composing": 1,
"G.": 1,
"The": 1,
"functions": 2,
"composed": 1,
"create": 1,
"compiled": 1,
"which": 1,
"behaves": 1,
@@ -56289,7 +56630,6 @@
"syntax": 1,
"highlighting": 1,
"functions_to_compose": 2,
"Term": 10,
"Funcs": 7,
"functor": 1,
"Op": 3,
@@ -56310,9 +56650,7 @@
"compile_predicates": 1,
"Output": 2,
"compound": 1,
"setof": 1,
"arg": 1,
"Name": 2,
"Args0": 2,
"nth1": 2,
"lib": 1,
@@ -56323,11 +56661,9 @@
"#": 9,
"labeling": 2,
"vabsIC": 1,
"or": 1,
"faitListe": 3,
"First": 2,
"Taille": 2,
"Min": 2,
"Max": 2,
"Min..Max": 1,
"Taille1": 2,
@@ -56382,7 +56718,6 @@
"Rs1": 2,
"left": 4,
"stay": 1,
"right": 1,
"L": 2
},
"Propeller Spin": {
@@ -72851,7 +73186,7 @@
"PostScript": 107,
"PowerShell": 12,
"Processing": 74,
"Prolog": 2451,
"Prolog": 6916,
"Propeller Spin": 13519,
"Protocol Buffer": 63,
"PureScript": 1652,
@@ -73066,7 +73401,7 @@
"PostScript": 1,
"PowerShell": 2,
"Processing": 1,
"Prolog": 6,
"Prolog": 7,
"Propeller Spin": 10,
"Protocol Buffer": 1,
"PureScript": 4,
@@ -73133,5 +73468,5 @@
"fish": 3,
"wisp": 1
},
"md5": "a27211466edff986df556defef2e4e84"
"md5": "3778b7ad7414915c83e6960531006542"
}

1051
samples/Prolog/admin.pl Executable file

File diff suppressed because it is too large Load Diff