1#!/usr/bin/env swipl
    2
    3:- use_module(dataset).    4:- use_module(text).    5:- use_module(utils).    6:- use_module(search).    7
    8:- initialization(main, main).    9
   10main(_) :-
   11    text("saudation", Saudation),
   12    writeln(Saudation),
   13    conversation.
   14
   15conversation :-
   16    ask_user_interest(AreaOfInterest, Paradigm, TypeSystem),
   17    search_languages(AreaOfInterest, Paradigm, TypeSystem, LanguagesFound),
   18    (LanguagesFound \= []
   19        -> select_language_details(LanguagesFound)
   20        ; text("not_found", LanguagesNotFoundText),
   21          writeln(LanguagesNotFoundText),
   22          try_another_language
   23    ).
   24
   25ask_user_interest(AreaOfInterest, Paradigm, TypeSystem) :-
   26    text("area_interest", AreaOfInterestText),
   27    text("type-system", TypeSystemText),
   28    text("paradigm", ParadigmText),
   29    writeln(AreaOfInterestText),
   30    read(AreaOfInterest),
   31    writeln(TypeSystemText),
   32    read(TypeSystem),
   33    writeln(ParadigmText),
   34    read(Paradigm).
   35
   36select_language_details(LanguagesFound) :-
   37    text_languages_found(LanguagesFound, LanguagesFoundText),
   38    writeln(LanguagesFoundText),
   39    read(LanguageSelectedName),
   40    (search_by_name(
   41            LanguageSelectedName, 
   42            LanguagesFound, 
   43            LanguageSelected)
   44        -> text_languages_details(LanguageSelected, TextFormated),
   45           writeln(TextFormated)
   46        ; text("not_found", LanguagesNotFoundText),
   47          writeln(LanguagesNotFoundText)
   48    ),
   49    try_another_language.
   50
   51try_another_language :-
   52    text("want_try_another", WantTryAnotherText),
   53    writeln(WantTryAnotherText),
   54    read(WantTryAnotherAnswer),
   55    (is_positive_answer(WantTryAnotherAnswer)
   56        -> conversation
   57        ;  text("bye", ByeText),
   58           writeln(ByeText)
   59    )