Skip to content

Commit

Permalink
Merge branch 'release/1.0.0' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
arobirosa committed Feb 20, 2024
2 parents 8a4ae31 + 4ff9e2c commit 31b5ea9
Show file tree
Hide file tree
Showing 35 changed files with 969 additions and 208 deletions.
19 changes: 19 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.github
.idea
.settings
db
docker
docs
packs/Downloads
packs/.gitkeep
src/packs.pl
src/scratch.pl
webDesign
.gitignore
.project
computer-repair-ai-assistant-prolog.iml
Dockerfile
LICENSE
README.md
run_all_tests.sh
run.sh
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Log entries**
Please add any logged error or warning here or as an attachment

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/sonarlint/
.idea/consolestorage/
src/scratch.pl
packs/
2 changes: 1 addition & 1 deletion .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/fileTemplates/includes/File Header.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM swipl:stable
COPY . .
ENTRYPOINT ["swipl", "start.pl"]
EXPOSE 8080
LABEL org.opencontainers.image.source=https://github.com/arobirosa/computer-repair-ai-assistant-prolog
LABEL org.opencontainers.image.description="AI Computer Assistant. Proof of concept to evaluate the use of knowledge representation and reasoning (KRR) systems "
LABEL org.opencontainers.image.licenses=Apache-2.0
100 changes: 35 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ contracts and other documents.

# Conclusions reached after developing the assistant

TODO Complete this section

## Positive points
* **Easy to understand how the assistant reached a conclusion**
* **It is easy to understand how the assistant reached a conclusion**
* **The knowledge base is incremental**. The customer can start with a few cases and add new ones as soon as they appear in the real world.
* The reasoning has high-precision when no probabilities are used
* The [graphical debugger](https://www.swi-prolog.org/pldoc/man?section=start-guitracer) is useful and pretty easy to use, once you have set the breakpoints
Expand Down Expand Up @@ -53,6 +51,7 @@ I can open the uniprot database without issues in Intellij IDEA and [DB Browser
* There aren't any prolog programmers in the market. Prolog is more difficult to understand as a language than object-oriented or imperative languages like Java or Python

## Neutral points
* The strenghts of prolog are knowledge, logic and integration with other programming languages. As long as you work in the logical programming paradigm the code is elegant, easy to read and can be easily tested. If you jump into the imperative paradigm by creating a website, the resulting code for generating the HTML page is ugly, long and error prone and the internals are difficult to follow.
* The SWI Prolog implementation is mature for commercial projects.
* The IDEs have poor support for Prolog. Intellij IDEA supports Prolog syntax highlighting using the plug-in Logtalk. The Prolog plugin is not compatible with version 2022.1.3

Expand All @@ -65,105 +64,76 @@ I can open the uniprot database without issues in Intellij IDEA and [DB Browser
:white_check_mark: An user without training can use the assistant. He only needs to how to start the expert system in his language. \
:x: An user with simple steps can add new causes and symptoms :rage:
:white_check_mark: The messages and inputs can be internationalised in different languages Prolog isn't expected to be used interacting directly with the user, so I implemented this minimally. \
- [ ] The assistant works on Windows or can be used with a browser Prolog isn't expected to be used interacting directly with the user
:white_check_mark: The assistant can be used with a browser or works on Windows. Prolog isn't expected to be used interacting directly with the user. Please see [Integration posibilities](docs/integrationPosibilities.md) \
:white_check_mark: Automatic tests for the assistant can be written \

## Should Have
:white_check_mark: It is possible to log errors, warnings, informational and debug messages. On SWI Prolog this is done with print_message/1 as with the i18n \
- [ ] The entered symptoms can be saved. And an user can restored a previously saved session
- [ ] The assistant can be integrated in a website or delivered as a separated programme
- [ ] It is possible to add causes which only affect some computer models
- [ ] The entered symptoms can be saved. And an user can restore a previously saved session. **Possible but not implemented** \

:white_check_mark: The assistant can be integrated in a website or delivered as a separated programme. Please see [Integration posibilities](docs/integrationPosibilities.md)

- [ ] It is possible to add causes which only affect some computer models. **Possible but not implemented**

## Could have - Nice to have
- [ ] The assistant can be called from a Java programme
- [ ] The assistant can be called from a Java programme. **Possible but not implemented** Please see [Integration posibilities].(docs/integrationPosibilities.md)

## Won't have

* Diagnostic using probability because this can be better modelled with **machine learning** and this could make the diagnostic **difficult to explain**

## TODO Tasks

Try the pack [instant_prolog_docs](https://www.swi-prolog.org/pack/list?p=instant_prolog_docs) to see if it documents predicates better than AI code assistant which work for any programming language.

# Installation

On a linux box run

~~~
sudo apt-get install swi-prolog
swipl --version
~~~
You should see something similar to **SWI-Prolog version 9.0.4 for x86_64-linux**.

Go into the git repository and install all the dependencies:
~~~
swipl src/packs.pl
~~~

# Usage

On the root directory of the repository run:
~~~
swipl start.pl
~~~
You can use the parameter --language to specify the language of the messages. For example: de, es or en. The default is en.

Then browse to http://localhost:8080

## How to build and run it inside a Docker container
On the root directory of the repository run:
~~~
swipl src/computer-repair-assistant.pl
sudo docker build -t computer_assistant:1.0 .
sudo docker run -p 8080:8080 computer_assistant:1.0
~~~
Then browse to http://localhost:8080

# How to contribute

* As an user, you can create issues with errors or ideas for improvemets
* As a developer, you can extend the knowledge base, correct errors or make improvements. I recommend you to use Intellij IDEA as IDE, open a terminal window, run **swipl src/computer-repair-assistant.pl** and make tests in the interactive mode. You can reload the source code by entering **make.**.
* As a developer, you can extend the knowledge base, correct errors or make improvements. I recommend you to use Intellij IDEA as IDE, open a terminal window, run **swipl src/computer-repair-assistant.pl** and make tests in the interactive mode. You can reload the source code by entering **make.**. Please take a look at the [definition of done for each pull request](docs/Definition-of-Done.md)

# Acknowledgment

The diagnostic and symptoms were inspired from the diagrams of this [expert system created by Gena Charnukha](https://roboticsandenergy.com/projects/expert-program-computer-project/). Because I structured my expert system in another way, no code from this project was used.

# Evaluation of Prolog implementations and development environments

The following ones were evaluated for use in this project:

* [SWI-Prolog](https://www.swi-prolog.org/) **Choosen**. It can link Prolog predicates to an SQL database, Java and Python. It can work on both Windows and Linux-based systems. It can be used to create Web Applications
* [Prolog Development Tool - PDT](Prolog Development Tool - PDT) **Choosen** It has a console to execute any predicate while working on a prolog script. This is better than the support provided by Intellij IDEA with the Logtalk plugin.

[Table with all implementations of Prolog](https://en.wikipedia.org/wiki/Comparison_of_Prolog_implementations)

### Discarded

* [ErgoAI](https://github.com/ErgoAI) Documentation is poor. Discarded. It can link Prolog predicates to an SQL database, Java and Python
* [Visual Prolog](https://www.visual-prolog.com/) Discarded. It only works on Windows and its syntax is propietary.
* [XSB: a deductive database](https://xsb.sourceforge.net/) It is used by ErgoAI internally.
* [GNU Prolog](https://www.gprolog.org/) It can't use databases to get predicates
* [ECLiPSe is an open-source software system for the cost-effective development and deployment of constraint programming applications, e.g. in the areas of planning, scheduling, resource allocation, timetabling, transport etc.](http://www.eclipseclp.org/) Better for constraint based problems
* [Jprolog](https://github.com/jiprolog/jiprolog/releases) The website is outdated and the last change was on 2015.
Please read the [results of the Evaluation of Prolog implementations and development environments here](docs/prologImplementationsEvaluation.md)

# Other projects using prolog to create (medical) expert systems:

* [Medical Diagnosis system using Prolog created by Shiddika Jahan Bushra](https://github.com/sjbushra/Medical-Diagnosis-system-using-Prolog/) This is a clean way to create an expert system. Please be aware that the license of the code is unclear so it is better not to reuse that code.
* [NephroDoctor created by Nicola Dileo and Tommaso Viterbo](https://github.com/nicoladileo/NephroDoctor) Shows how to make diagnostic using probability, modify the answers and save the symptoms to a file
* [Medical Expert System for COVID-19 from Rojay White and others](https://github.com/R-White-0/Medical-Expert-System) It uses 3 or more symptoms
to diagnostic COVID-19. It shows how to use windows, messages boxes and checkboxes to ask for user imput with Prolog. Notice: Works locally but not on the online version of SWI Prolog.



--------

TODO The next sections must be organized


https://www.swi-prolog.org/pldoc/man?predicate=style_check/1
https://www.gyaanibuddy.com/assignments/assignment-detail/medical-diagnosis-in-prolog/
https://swish.swi-prolog.org/example/movies.pl
https://www.swi-prolog.org/download/stable
https://www.swi-prolog.org/pldoc/man?section=implhistory

# Prolog code fixers

TODO Check if they work

https://codepal.ai/code-fixer/prolog
https://codingfleet.com/code-assistant/prolog/
You will find [other projects and academic papers here](docs/projectsUsingPrologToCreateExpertSystems.md)

# Other projects
[Medical diagnosis in prolog](https://www.gyaanibuddy.com/assignments/assignment-detail/medical-diagnosis-in-prolog/)
[Expert program computer project of Robotics and Energy](https://roboticsandenergy.com/projects/expert-program-computer-project/)
[SHEPHERD: Deep learning for diagnosing patients with rare genetic diseases](https://github.com/mims-harvard/SHEPHERD)
[Proof-of-concept (POC) of a medical diagnosis system using a probabilistic expert system, which is based on Noisy-or Bayesian Network Model.](https://github.com/hidiryuzuguzel/medical-expert-system-poc/tree/master)
# Contact me for inquiries about expert systems and other AI technologies

# Papers
If you have a problem or process which might be solved or improved using Expert System or other AI technology, I could help you find out what tools and technologies will be useful for it.

https://arxiv.org/pdf/2110.04439.pdf
https://www.semanticscholar.org/paper/PROLOG-EXPERT-SYSTEM%3A-THE-DIAGNOSIS-OF-KIDNEY-Roventa-Ro%C8%99u/349a7cc2ccbe9ab0ab562467eaaf259d46ab7e3e
file:///home/arobirosa/Downloads/450-Article%20Text-1399-1-10-20150224.pdf
https://dl.acm.org/doi/abs/10.1145/3487664.3487728
https://www.jstage.jst.go.jp/article/pjsai/JSAI2021/0/JSAI2021_4N3IS1b01/_pdf
https://scholarworks.calstate.edu/downloads/hd76s295t
Just send me a message to my GitHub email address.
53 changes: 53 additions & 0 deletions css/naturedesign.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
body .container #wc_output
{
border: none;
}

form.inactive
{ color: #ccc;
}

#preview h1,address
{ display: none;
}

body {
background-color: forestgreen;
}

.container p {
color: #AEF062;
padding-left: 20px;
}

.container .row {
color: white;
}

body h1 {
font-weight: bold;
color: #AEF062;
}

.container .form-group {
background-color: #AEF062;
}

.container .form-group p {
color: white;
padding-left: 20px;
padding-top: 20px;
}

.container .form-group .btn-group {
padding-left: 20px;
padding-bottom: 20px;
}

.container table tr td {
color: green;
}

.container table tr th {
color: #F0BE62;
}
9 changes: 9 additions & 0 deletions docs/Definition-of-Done.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
* Code compiles when loaded into SWIPL
* All old tests are working
* The test coverage is equal or higher to 70% of the lines. :warning: Currently not working
* The new tests are meaningful
* Code is commited in the Github repository and no files or changes are missing
* The change was tested
* The feature is documented on the README or doc files.
* The ticket is closed

File renamed without changes.
21 changes: 21 additions & 0 deletions docs/projectsUsingPrologToCreateExpertSystems.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Other projects using prolog to create (medical) expert systems:

* [Medical Diagnosis system using Prolog created by Shiddika Jahan Bushra](https://github.com/sjbushra/Medical-Diagnosis-system-using-Prolog/) This is a clean way to create an expert system. Please be aware that the license of the code is unclear so it is better not to reuse that code.
* [NephroDoctor created by Nicola Dileo and Tommaso Viterbo](https://github.com/nicoladileo/NephroDoctor) Shows how to make diagnostic using probability, modify the answers and save the symptoms to a file
* [Medical Expert System for COVID-19 from Rojay White and others](https://github.com/R-White-0/Medical-Expert-System) It uses 3 or more symptoms
to diagnostic COVID-19. It shows how to use windows, messages boxes and checkboxes to ask for user imput with Prolog. Notice: Works locally but not on the online version of SWI Prolog.

# Other projects
* [Medical diagnosis in prolog](https://www.gyaanibuddy.com/assignments/assignment-detail/medical-diagnosis-in-prolog/) Exercise to practice
* [SWISH Movies exercise to practice doing queries](https://swish.swi-prolog.org/example/movies.pl)
* [Expert program computer project of Robotics and Energy](https://roboticsandenergy.com/projects/expert-program-computer-project/)
* [SHEPHERD: Deep learning for diagnosing patients with rare genetic diseases](https://github.com/mims-harvard/SHEPHERD)
* [Proof-of-concept (POC) of a medical diagnosis system using a probabilistic expert system, which is based on Noisy-or Bayesian Network Model.](https://github.com/hidiryuzuguzel/medical-expert-system-poc/tree/master)

# Academic Papers related to expert systems

* [A Generic Knowledge Based Medical Diagnosis Expert System](https://arxiv.org/pdf/2110.04439.pdf)
* [Prolog Expert System: the diagnosis of kidney diseases](https://www.semanticscholar.org/paper/PROLOG-EXPERT-SYSTEM%3A-THE-DIAGNOSIS-OF-KIDNEY-Roventa-Ro%C8%99u/349a7cc2ccbe9ab0ab562467eaaf259d46ab7e3e)
* [Design and implementation of a SWI-Prolog-based expert system to
diagnose anxiety disorder](https://www.jstage.jst.go.jp/article/pjsai/JSAI2021/0/JSAI2021_4N3IS1b01/_pdf)
* [Prolog and Inductive Reasoning: A Logic Programming Language](https://scholarworks.calstate.edu/downloads/hd76s295t)
17 changes: 17 additions & 0 deletions docs/prologImplementationsEvaluation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Evaluation of Prolog implementations and development environments

The following ones were evaluated for use in this project:

* [SWI-Prolog](https://www.swi-prolog.org/) **Choosen**. It can link Prolog predicates to an SQL database, Java and Python. It can work on both Windows and Linux-based systems. It can be used to create Web Applications
* [Prolog Development Tool - PDT](https://sewiki.iai.uni-bonn.de/research/pdt/docs/start) **Choosen** It has a console to execute any predicate while working on a prolog script. This is better than the support provided by Intellij IDEA with the Logtalk plugin.

[Table with all implementations of Prolog](https://en.wikipedia.org/wiki/Comparison_of_Prolog_implementations)

### Discarded

* [ErgoAI](https://github.com/ErgoAI) Documentation is poor. Discarded. It can link Prolog predicates to an SQL database, Java and Python
* [Visual Prolog](https://www.visual-prolog.com/) Discarded. It only works on Windows and its syntax is propietary.
* [XSB: a deductive database](https://xsb.sourceforge.net/) It is used by ErgoAI internally.
* [GNU Prolog](https://www.gprolog.org/) It can't use databases to get predicates
* [ECLiPSe is an open-source software system for the cost-effective development and deployment of constraint programming applications, e.g. in the areas of planning, scheduling, resource allocation, timetabling, transport etc.](http://www.eclipseclp.org/) Better for constraint based problems
* [Jprolog](https://github.com/jiprolog/jiprolog/releases) The website is outdated and the last change was on 2015.
Loading

0 comments on commit 31b5ea9

Please sign in to comment.