ontologyportal / sigmakee

Sigma Knowledge Engineering Environment
https://www.ontologyportal.org
GNU General Public License v3.0
103 stars 35 forks source link

Notice

2024 November 2 - We're making some improvements to clean up the configuration and code of Sigma and its associated projects. For existing installations, some changes are needed to stay in sync. OpenJDK is now supported, eliminating the dependency on Oracle JDK. Tomcat 9 is now required. A new environment variable SIGMA_CP is now required in your .bashrc (or similar for non-Linux). Please let us know if you have any issues!

To upgrade to Tomcat 9 and add the SIGMA_CP:

cd ~
echo "export SIGMA_CP=$SIGMA_SRC/build/sigmakee.jar:$SIGMA_SRC/lib/*" >> .bashrc
cd Programs
rm -r apache-tomcat-8.5.23/
wget 'https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.97/bin/apache-tomcat-9.0.97.zip'
unzip apache-tomcat-9.0.97.zip
rm apache-tomcat-9.0.97.zip
cd ~/Programs/apache-tomcat-9.0.97/bin
chmod 777 *
cd ../webapps
chmod 777 *

update CATALINA_HOME in your ~/.bashrc file

CATALINA_HOME=~/Programs/apache-tomcat-9.0.97

Recompile sigmakee

cd ~/workspace/sigmakee/
ant

Introduction

Sigma is an integrated development environment for logical theories that extend the Suggested Upper Merged Ontology (SUMO). There is a public installation with read-only functions enabled linked from http://www.ontologyportal.org

Warning Please read these notes thoroughly if you want to do a native install not with a container. Most installation issues result from not carefully following the instructions.

You can follow the steps below to do a manual installation on linux or Mac. This procedure assumes that you start from your home directory and are happy with having directories created there. The sed command below attempts to modify ~/.sigmakee/KBs/config.xml to conform to your local paths. If your paths differ, then you may need to edit your config.xml manually. If you are running tomcat on vagrant or another VM, you may need to change the port value from 8080. If you are running on a server, rather than your localhost you'll need to set the hostname parameter in your config.xml file. E will only work if your $TMPDIR is set correctly. Tomcat V9 is required. Later versions of Tomcat are not yet supported. Be sure to change $CATALINA_HOME and your paths to conform to the version. If you use a different mirror or version you'll need to change the wget commend below. Change "theuser" below to your user name.

If your installation isn't working and you're getting funny "null"s in your paths try opening permissions on your $SIGMA_HOME, $CATALINA_HOME and $SIGMA_SRC directories.

After installing, recommended reading is the Sigma manual https://github.com/ontologyportal/sigmakee/blob/master/doc/manual/SigmaManual.pdf There is a video on installing Sigma, as well as many others about related tools at https://www.youtube.com/playlist?list=PLpBQIgki3izeUmFD8c65INdmxRNjjxOzP

Container-Based installation

First, install docker if you don't have it already

sudo apt-get update
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
sudo apt-get update
sudo apt-get install docker-ce

Then get the docker image and run it

Pull with

sudo docker pull apease/sigmakee:latest

Run with

sudo docker run -it -d -p 8080:8080 --name trial04 apease/sigmakee:latest

Access from a browser with http://localhost:8080/sigma/login.html . Use admin for username and admin for password

Vagrant Virtual Machine installation

Warning Vagrant build is not maintained. Original vagrant files can be found in attic

Build a New Docker Image

Please note that the Docker container version of Sigma is several years out of date. A native install of Sigma is recommended.

To build a new docker container follow these steps where $SIGMA_SRC is your sigmakee git repo path. First, download Linux/x64 from https://download.java.net/java/GA/jdk23/3c5b90190c68498b986a97f276efd28a/37/GPL/openjdk-23_linux-x64_bin.tar.gz Note that if you don't download that exact version, you'll need to edit sigmastart.sh so that the filename matches. You'll also need to make changes to track the latest Tomcat, in the bashrc and Dockerfile

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
sudo apt-get update
sudo apt-get install docker-ce
mkdir images
cd images
cp $SIGMA_SRC/docker/* .
sudo docker build -t sigmakee2018:latest .

to push the image to dockerhub

>:~/images$ sudo docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username (apease):
Password:
Login Succeeded

>:~/images$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                    NAMES
1f7d0cef7874        51a041125329        "./sigmastart.sh"   56 minutes ago      Up 56 minutes       0.0.0.0:4000->8080/tcp   trial11
>:~/images$ sudo docker tag 51a041125329 apease/sigmakee2018:latest
>:~/images$ sudo docker push apease/sigmakee2018:latest
The push refers to a repository [docker.io/apease/sigmakee2018]
ab5e94769be7: Pushed
1c15947f83dc: Pushed
c2007c9776df: Pushed
829ef5b0378d: Pushed
6fd852e99bda: Pushed
85c7d96adccb: Pushed
6b2f14c09222: Pushed
9a9a3d9cc4bc: Pushed
38c81b36edfb: Pushed
bcc97fbfc9e1: Pushed
latest: digest: sha256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx size: 2417

System preparation on Linux

Make sure that throughout the commands below that you replace "theuser" with your desired user name

create user theuser

sudo useradd theuser

add password for theuser

sudo passwd theuser

add to sudoers file

sudo usermod -aG sudo theuser

switch over to the new user

su theuser
cd /home
sudo mkdir theuser
sudo chown theuser theuser
cd theuser

make sure you're running bash (and answer /bin/bash)

chsh

Install unzip

sudo apt-get install unzip
sudo apt-get update

Install git

sudo apt-get install git

Install ant

sudo apt-get install ant

Install make

sudo apt-get install make

Install cmake

sudo apt-get install cmake

Install gcc

sudo apt-get install gcc

Install graphViz

sudo apt-get install graphviz

Update apt-get

sudo add-apt-repository universe
sudo apt-get update

may need to create a .bashrc

touch .bashrc

handy to add stuff to .bashrc

echo "alias dir='ls --color=auto --format=vertical -la'" >> .bashrc
echo "export HISTSIZE=10000 HISTFILESIZE=100000" >> .bashrc
echo "export JAVA_HOME=/home/theuser/Programs/jdk-23" >> .bashrc

load the definitions into your environment

source .bashrc

then you can add the last one

echo "export PATH=$PATH:$JAVA_HOME/bin" >> .bashrc
source .bashrc
mkdir /home/theuser/Programs
cd Programs

Install a Java Development Kit (JDK) from OpenJDK, at least version 21 or greater. Avoid JDK 17

The following command line version may work but you may need to update the name of the jdk zipfile

wget https://download.java.net/java/GA/jdk23/3c5b90190c68498b986a97f276efd28a/37/GPL/openjdk-23_linux-x64_bin.tar.gz
  gunzip openjdk-23_linux-x64_bin.tar.gz

Copy the download link into this command. Then you need two commands to install the new Java (check that the paths conform to the java version you downloaded) -

sudo update-alternatives --install "/usr/bin/java" "java" "/home/theuser/Programs/jdk-23/bin/java" 1
sudo update-alternatives --set java /home/theuser/Programs/jdk-23/bin/java

Verify that it's installed correctly with

java -version

You should see something like -

openjdk version "23" 2024-09-17
OpenJDK Runtime Environment (build 23+37-2369)
OpenJDK 64-Bit Server VM (build 23+37-2369, mixed mode, sharing)

Verify that you see the same Java version when you startup Apache Tomcat that you do when you run java -version . It's also a good idea to run javac -version to verify that you have installed the full JDK and not just te JRE.

On AWS it helps to be reminded of which server you're on. I use machine size as a reminder with

export HOST_TYPE=`curl http://169.254.169.254/latest/meta-data/instance-type`
PS1="$HOST_TYPE:"PS1

or on Vagrant, something like

PS1=Vagrant:$PS1

Linux Installation

First, comply with System preparation on Linux above

Clone SigmaKEE

git clone https://github.com/ontologyportal/sigmakee

Then,

cd sigmakee
ant install

The following steps are now legacy. The call to ant install above will perform\ these steps more efficiently.

cd ~
mkdir workspace
mkdir Programs
cd Programs
wget 'https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.97/bin/apache-tomcat-9.0.97.zip'
wget 'https://wordnetcode.princeton.edu/3.0/WordNet-3.0.tar.gz'
wget 'https://wwwlehre.dhbw-stuttgart.de/~sschulz/WORK/E_DOWNLOAD/V_2.0/E.tgz'
tar -xvzf E.tgz
unzip apache-tomcat-9.0.97.zip
rm apache-tomcat-9.0.97.zip
cd ~/Programs/apache-tomcat-9.0.97/bin
chmod 777 *
cd ../webapps
chmod 777 *
cd ~/workspace/
git clone https://github.com/ontologyportal/sigmakee
git clone https://github.com/ontologyportal/sumo
git clone https://github.com/ontologyportal/TPTP-ANTLR
git clone https://github.com/ontologyportal/SigmaUtils
cd ~
mkdir .sigmakee
cd .sigmakee
mkdir KBs
cp -R ~/workspace/sumo/* KBs
me="$(whoami)"
cp ~/workspace/sigmakee/config.xml ~/.sigmakee/KBs
sed -i "s/theuser/$me/g" KBs/config.xml
cd ~/Programs
gunzip WordNet-3.0.tar.gz
tar -xvf WordNet-3.0.tar
cp WordNet-3.0/dict/* ~/.sigmakee/KBs/WordNetMappings/
cd ~/Programs/E
./configure
make
make install
cd ~
echo "export SIGMA_HOME=~/.sigmakee" >> .bashrc
echo "export ONTOLOGYPORTAL_GIT=~/workspace" >> .bashrc
echo "export SIGMA_SRC=$ONTOLOGYPORTAL_GIT/sigmakee" >> .bashrc
echo "export CATALINA_OPTS=\"$CATALINA_OPTS -Xmx10g -Xss1m\"" >> .bashrc
echo "export CATALINA_HOME=~/Programs/apache-tomcat-9.0.97" >> .bashrc
echo "export PATH=$CATALINA_HOME/bin:$PATH" >> .bashrc
echo "export SIGMA_CP=$SIGMA_SRC/build/sigmakee.jar:$SIGMA_SRC/lib/*" >> .bashrc
source .bashrc
cd ~/workspace/sigmakee
ant

End legacy Linux install

To test run

java -Xmx10g -Xss1m -cp $SIGMA_CP \
    com.articulate.sigma.KB -c Object Transaction

Start Tomcat with

$CATALINA_HOME/bin/startup.sh

or simply

startup.sh

since $CATALINA_HOME/bin is on your PATH

Point your browser at http://localhost:8080/sigma/login.html Default credentials are: admin/admin

Debugging

Vampire

If you want to use Vampire instead of or in addition to E, follow these instructions. Please note that the command:

ant install

will also install Vampire

Older instructions

You may need to install the Zlib library if you don't have it already installed

sudo apt-get install libz-dev

and also possibly

sudo apt-get install g++

then execute the following:

cd $ONTOLOGYPORTAL_GIT
git clone https://github.com/vprover/vampire
cd vampire
make vampire_rel
mv vampire_rel_master* vampire

You'll then need to edit your config.xml file to point to the vampire executable. Add the line

  <preference name="vampire" value="/home/theuser/workspace/vampire/vampire" />

editing the path to conform to your system

If you want to use Vampire with options different from Avatar or the latest CASC strategy, for example, an older CASC strategy, you can set an environment variable, as in the assignment below, being sure to terminate with -t for the timeout

VAMPIRE_OPTS="--mode portfolio --avatar off -qa answer_literal --schedule casc_2019 --proof tptp -t"

MacOS install notes

See INSTALL.MacOS

Windows Subsystem for Linux Install Notes

Open up CMD prompt

    wsl –install
    .bashrc already existed in home directory. Did not update path.
    echo "alias dir='ls --color=auto --format=vertical -la'" >> .bashrc
    Manually changed with "nano .bashrc" HISTSIZE=10000 and HISTFILESIZE=100000
    mkdir /home/theuser/Programs
    cd Programs
    sudo apt-get install openjdk-23-jdk
    (This step might not be necessary, I'd try without it first) echo "export JAVA_HOME=/usr/lib/jvm/java-23-openjdk-amd64/jre" >> .bashrc

Follow Linux install instructions on:

https://github.com/ontologyportal/sigmakee

Modify the following files, replace "theuser" with your username

me="$(whoami)"
sed -i "s/theuser/$me/g" ~/workspace/sigmakee/config.xml
sed -i "s/theuser/$me/g" ~/workspace/sigmakee/test/unit/java/resources/config_all.xml
sed -i "s/theuser/$me/g" ~/workspace/sigmakee/test/unit/java/resources/config_topAndMid.xml
sed -i "s/theuser/$me/g" ~/workspace/sigmakee/test/integration/java/resources/config_all.xml
sed -i "s/theuser/$me/g" ~/workspace/sigmakee/test/integration/java/resources/config_topAndMid.xml
sed -i "s/theuser/$me/g" ~/workspace/sigmakee/test/integration/java/resources/config_topOnly.xml

jEdit Integration (optional)

If you install jEdit (see http://jedit.org) and configure Sigma properly, you can click on a source file and line number for a statement in the Sigma Browse page and be taken to the editor, open on that line. By default, the edit feature will make use of your $ONTOLOGYPORTAL_GIT environment variable, and try to open the file in that location in the "sumo" module. Recommended practice is to edit .kif files in your local Git repository and then copy them to the .sigmakee/KBs directory. If you wish to edit in a different location, either a different repository or a different directory altogether, the you can set the editDir configuration variable in your config.xml file, for example

  <preference name="editDir" value="/home/user/workspace/myproject" />

If you wish to install jEdit so that there's no path to it, for example on a shared machine as a user-specific program, you'll need to set a path in config.xml, for example

  <preference name="jedit" value="/home/user/jedit/jedit" />

jUnit testing on the command line

java -Xmx10g -Xss1m -cp $SIGMA_CP:\
  $SIGMA_SRC/build/test/classes \
  org.junit.runner.JUnitCore \
  com.articulate.sigma.UnitTestSuite

one test method at a time can be run with help from the SingleJUnitTestRunner class, for example

java -Xmx10g -Xss1m -cp $SIGMA_CP:\
  $SIGMA_SRC/build/test/classes \
  com.articulate.sigma.SingleJUnitTestRunner \
  com.articulate.sigma.KbIntegrationTest#testIsChildOf3

You will have to edit the resources files that correspond to config.xml to conform to your paths. They are in test/integration/java/resources/config.xml and test/unit/java/resources/config.xml

RESTful Interface

see the SigmaRest project - https://github.com/ontologyportal/SigmaRest

Python Interface

make sure you have python3

python --version

make sure you have pip or install with

sudo apt install python3-pip

install the py4j module

pip3 install py4j

Compile SigmaKEE then run with

java -Xmx10g -Xss1m -cp $SIGMA_CP com.articulate.sigma.KBmanager -p

then start python

user@user-machine:~/workspace/sigmakee$ python3
Python 3.8.2 (default, Jul 16 2020, 14:00:26)
[GCC 9.3.0] on linux

Type "help", "copyright", "credits" or "license" for more information.
>>> from py4j.java_gateway import JavaGateway
>>> gateway = JavaGateway()
>>> sigma_app = gateway.entry_point
>>> print(sigma_app.getTerms())

set([u'-1', u'-3', u'-6', u'-7235', u'.5', u'<=>', u'=>', u'AAA-Rating', u'AAM', u'AAV', u'ABPFn', u'ABTest', u'ACPowerSource', ...

Look at com.articulate.sigma.KBmanager.pythonServer() to expose the API of more classes than just com.articulate.sigma.KB

Account Management

Create the account database with

java -Xmx4g -cp $SIGMA_CP com.articulate.sigma.PasswordService -c

Then create the administrator account and password

java -Xmx4g -cp $SIGMA_CP com.articulate.sigma.PasswordService -a

You can use Sigma without being administrator, but you'll have limited use of its functionality.

You'll also need to set a few parameters in your config.xml file

  <preference name="dbUser" value="sa" />
  <preference name="loadFresh" value="false" />

To handle the account registration feature, you'll need to have an email account and supply the password in the .bashrc file where your Sigma installation is runnning. Gmail might be convenient for this. Change the password "my_pass" to your password on Gmail (or other service that you specify)

export SIGMA_EMAIL_PASS="my_pass"
export SIGMA_EMAIL_SERVER="smtp.gmail.com"

There are three types of user roles: "guest", "user" and "admin". Guests are users who have not registered. They can access read-only functions that are not computationally expensive. Registered users are granted access to computationally more expensive features. Admin users have access to all Sigma functions. Currently, this control is hard coded into the JSP pages that will check for user roles. At some point in the future this may be changed to a more flexible scheme of access rights driven from a file or database mapping roles to allowed functions.

You'll need to start the database server with

 java -jar lib/h2-2.3.232.jar -webAllowOthers -tcpAllowOthers

and you'll need to change JDBCstring in PasswordService.java to your path instead of /home/apease and recompile

Old Installation Notes

Install via script from source on Linux or Mac OS with

bash <(curl -L https://raw.githubusercontent.com/ontologyportal/sigmakee/master/install.sh)

Note that you need to enter the entire statement above, including calling "bash".

Users should also see

https://sourceforge.net/p/sigmakee/wiki/required_data_files/ Mac instructions - https://sourceforge.net/p/sigmakee/wiki/Sigma%20Setup%20on%20Mac/ Ubuntu - https://sourceforge.net/p/sigmakee/wiki/Setting%20up%20Sigma%20on%20Ubuntu/

To build/run/debug/test using the NetBeans IDE

Define a nbproject/private/private.properties file with these keys:

# private properties\ javaapis.dir=${user.home}/javaapis\ workspace=${javaapis.dir}/INSAFE

# The default installation space is: ~/workspace. However, it can be anywhere on\ # your system as long as you define the "workspace" key above.

catalina.home=${path.to.your.tomcat9}

private.resources.dir=nbproject/private/resources\ main.config=${private.resources.dir}/config.xml\ integration.config=${private.resources.dir}/config_topAndMid.xml\ unit.config=${private.resources.dir}/config_topOnly.xml

# The above properties allow you to keep and restore the various forms of\ # config.xml that get overwritten when running Unit Tests. Copy these files\ # to the respective "resources" directory complete with your personal system\ # paths replacing the "/home/theuser/" pseudos. config.xml is found in the\ # base directory and the other two are found in test/*/resources directories

# JavaMail properties\ user=${your.email.user.name}\ my.email=${user}@${your.email.domain}\ my.name=${your.name}

User Interface

There's not enough documentation on Sigma so I'm starting a bit here in preparation for a real manual.

Sigma has a number of functions controlled through its JSP-based interface.