Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tidying up...

  • Loading branch information...
commit 0227826527ff6d6a9b47182153b19df72fb83ac8 1 parent 00acaa3
Simon Kaltenbacher authored
Showing with 29 additions and 35 deletions.
  1. +7 −6 interface.pl
  2. +5 −9 rdf.pl
  3. +17 −20 util.pl
View
13 interface.pl
@@ -16,7 +16,7 @@
:- consult('recipes/*').
:- use_module(util).
-% TODO Mengenangaben im Fließtext umrechnen!
+% TODO Translate quantity information in continuous text!
% roundNot0(+Value, +N, ?RValue)
roundNot0(0, _, 0) :- !.
@@ -27,9 +27,10 @@
% optRep((+Value, +Unit), (?OptValue, ?OptUnit))
optRep((Value, Unit), (OptValue, OptUnit)) :-
translation(RefUnit, Factor1, Unit),
- findall((OptValue, OptUnit),
- (translation(RefUnit, Factor2, OptUnit), OptValue is Value * Factor1 / Factor2, OptValue >= 1),
- Reps),
+ findall(
+ (OptValue, OptUnit),
+ (translation(RefUnit, Factor2, OptUnit), OptValue is Value * Factor1 / Factor2, OptValue >= 1),
+ Reps),
sort(Reps, [(OptValue, OptUnit)|_]), !.
optRep((Value, Unit), (Value, Unit)).
@@ -106,7 +107,7 @@
resolveName(PQuantity, unit, PUnit, UnitName),
write(PQuantity), write(' '), write(UnitName), write(' '), write(IngName).
-% printPreparation
+% printPreparation(+Id)
printPreparation(Id) :-
rec(Id, preparation, Text),
write(Text), nl.
@@ -147,7 +148,7 @@
rec(Id, persons, Persons2),
forall(rec(Id, ingredient, S), (printIng(S, Persons1 / Persons2 * Factor), nl)).
-%name
+% name(?Name)
name(Name) :- rec(_, name, Name).
% listRecipes
View
14 rdf.pl
@@ -1,6 +1,9 @@
-:- module(rdf, [getId/6, wordScore/3]).
+:- module(rdf, [
+ getId/6, % getId(+SearchTerm, +Functor, ?Id, ?Score, ?Start, ?Name)
+ wordScore/3 % wordScore(+SW, +Words, ?Score)
+]).
-% TODO wordScore nicht exportieren!
+% TODO Do not export wordScore!
% :- multifile rec/3.
@@ -12,13 +15,6 @@
:- module_transparent([getId/6]).
-% getId(+SearchTerm, +Functor, ?Id, ?Prop, ?Start, ?Name)
-% getId(SearchTerm, Functor, Id, Prop, Start, Name) :-
-% call(Functor, Id, Prop, Name),
-% downcase_atom(SearchTerm, DSearchTerm),
-% downcase_atom(Name, DName),
-% once(sub_atom(DName, Start, _, _, DSearchTerm)).
-
% wordScore(+SW, +Words, ?Score)
wordScore(SW, Words, Score) :-
findall(
View
37 util.pl
@@ -1,14 +1,14 @@
:- module(util, [
- suffix/2,
- subList/2,
- round/3,
- group/2,
- groupByFirstLetter/2,
- printGroups/1,
- printListByFirstLetter/1,
- subset0/2,
- words/3,
- rkeysort/2
+ suffix/2, % suffix(?Suffix, ?List)
+ subList/2, % % subList(?SubList, ?List)
+ round/3, % round(+Value, +N, -RValue)
+ group/2, % group(+Pairs, ?Groups)
+ groupByFirstLetter/2, % groupByFirstLetter(+Names, -Groups)
+ printGroups/1, % printGroups(+Groups)
+ printListByFirstLetter/1, % printListByFirstLetter
+ subset0/2, % subset0(?Sub, ?Super)
+ words/3, % words(+Ws, ?Result, ?Rest)
+ rkeysort/2 % rkeysort(+List, -ReverseSorted)
]).
:- set_prolog_flag(optimise, true).
@@ -18,11 +18,11 @@
:- module_transparent listEntities/3.
-% suffix(?X, ?L)
-suffix(X, L) :- append(_, X, L).
+% suffix(?Suffix, ?List)
+suffix(S, L) :- append(_, S, L).
-% subList(?X, ?L)
-subList(X, L) :- suffix(S, L), prefix(X, S).
+% subList(?SubList, ?List)
+subList(SL, L) :- suffix(S, L), prefix(SL, S).
% round Value to N signficant digits.
% round(+Value, +N, -RValue)
@@ -38,8 +38,6 @@
call(G),
foldl(F, Acc2, Xs, Res).
-% findall((X, Y), (between(1, 20, X), between(1, 100, Y)), Pairs), group(Pairs, Group).
-
% group(+Pairs, ?Groups)
group([], []).
group([(K, V)|Ps], [(K, Vs)|Gs]) :-
@@ -59,6 +57,7 @@
RPs = [(Key, V)|Ps]
).
+% first_letters(+Letters, (?Key, ?Letters))
first_letters(Ls, (K, Ls)) :-
atom_chars(Ls, [Fst|_]),
atom_concat('# ', Fst, K).
@@ -82,8 +81,6 @@
groupByFirstLetter(SLs, Gs),
printGroups(Gs).
-% findall((1, X), between(1, 100, X), Pairs), span(Pairs, 1, Vs, Rps).
-
% Sub and Super are assumed to be ordered.
% subset0(?Sub, ?Super)
subset0([], []).
@@ -98,7 +95,7 @@
whitespace --> [' '], whitespace, !.
whitespace --> [].
-% words
+% words(+Ws, ?Result, ?Rest)
words(Ws) -->
whitespace,
(
@@ -107,5 +104,5 @@
[], {Ws = []}
).
-% rkeysort
+% rkeysort(+List, -ReverseSorted)
rkeysort(L, RS) :- keysort(L, S), reverse(S, RS).
Please sign in to comment.
Something went wrong with that request. Please try again.