Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Assess whether the user is of low income.
- low_income(X) :- X =< 20000.
- % Are they old enough to remember Margaret Thatcher? Assuming the user
- % had to be at least 5 years old in 1990 - ie the year of their birth
- % was 1985 or earlier.
- remembersThatcher(X) :- X =< 1985.
- % Count the number of hits in a list.
- %
- hits([], SearchList, 0). % If there are no search terms there can be no hits.
- hits([Head|Tail], SearchList, Sum) :-
- member(Head, SearchList),
- hits(Tail, SearchList, Temp),
- Sum is Temp + 1.
- hits([Head|Tail], SearchList, Sum) :-
- \+ member(Head, SearchList),
- hits(Tail, SearchList, Sum).
- education(graduate).
- education(none).
- gender(male). gender(m). gender(female). gender(f).
- toryLike(['nimbyIssues']).
- toryHate(['europe']).
- % Special Case, poor people who remember Margaret Thatcher will never vote Tory.
- neverVotesTory(AnualIncome, YearOfBirth) :-
- low_income(AnualIncome), remembersThatcher(YearOfBirth).
- % Establish a 'base level' based on socio-economic background.
- tory(_,_,_,_,_,_,0).
- tory(YearOfBirth, AnualIncome, MyEducation, graduate, Gender, [], [], Confidence) :-
- education(MyEducation),
- gender(Gender),
- \+ neverVotesTory(AnualIncome, YearOfBirth),
- Confidence is 1.
- tory(YearOfBirth, AnualIncome, MyEducation, FathersEducation, male, [], [], Confidence) :-
- education(MyEducation), education(FathersEducation),
- \+ neverVotesTory(AnualIncome, YearOfBirth),
- Confidence is 1 rdiv 2.
- % Multiply the Confidence value by 1 / the number of hated likes and
- % liked hates.
- tory(YearOfBirth, AnualIncome, MyEducation, FathersEducation, Gender, Likes, Dislikes, Confidence) :-
- education(MyEducation), education(FathersEducation),
- toryLike(ToryLike), toryHate(ToryHate),
- hits(ToryLike, Dislikes, Temp1), hits(ToryHate, Likes, Temp2),
- Temp3 is Temp2 + Temp1 + 1,!,
- tory(YearOfBirth, AnualIncome, MyEducation, FathersEducation, Gender, [], [], Temp),
- Confidence is Temp rdiv Temp3,
- writeln(MyEducation).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement