Skip to content

Commit

Permalink
pyswip/flybase_learn.pl
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSPoon committed Dec 2, 2023
1 parent 27b34bf commit 5557af7
Show file tree
Hide file tree
Showing 149 changed files with 7,107 additions and 1,761 deletions.
373 changes: 373 additions & 0 deletions .bash_history

Large diffs are not rendered by default.

54 changes: 33 additions & 21 deletions MeTTa
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,24 @@ export METTALOG_DIR=$(dirname "$SCRIPT")
#echo "METTALOG_DIR=$METTALOG_DIR"
cd "$METTALOG_DIR" || { echo "Failed to navigate to $METTALOG_DIR"; [[ "$IS_SOURCED" == "1" ]] && return 1 || exit 1; }

# Get the last argument
last_arg="${@: -1}"

# Check if the last argument is a directory
if [ -d "$last_arg" ]; then
echo "The last argument is a directory."
exec ./scripts/test_in_metta.sh -y $@
# Initialize the variable to indicate whether to use the test script
use_test_script=0

# Iterate over all command-line arguments
for arg in "$@"; do
# Check if the argument is a directory
if [ -d "$arg" ]; then
use_test_script=1
# Check for specific flags
elif [[ "$arg" == "--fresh" ]] || [[ "$arg" == "--clean" ]]; then
use_test_script=1
fi
done

# Execute the test script if the condition is met
if [[ "$use_test_script" -eq 1 ]]; then
exec ./scripts/test_in_metta.sh -y --report=n "$@"
fi


Expand Down Expand Up @@ -217,7 +228,7 @@ function handle_args {
if [[ -f "$arg" || -d "$arg" ]]; then
arg_realpath="$(realpath "$arg")"
if [[ -f "$arg_realpath" || -d "$arg_realpath" ]]; then
add_to_list "$arg_realpath" LIST_OF_FILE_ARGS
add_to_list "$arg_realpath" LIST_OF_FILE_ARGS
fi
add_to_list "$arg" OTHER_OPTIONS
else
Expand All @@ -237,8 +248,7 @@ DIRNAME="${LIST_OF_FILE_ARGS[0]}"
if [[ -f "$DIRNAME" ]]; then
DIRNAME=$(dirname "${DIRNAME}")
elif [[ -d "$DIRNAME" ]]; then
exec ./scripts/test_in_metta.sh -y $@
[[ "$IS_SOURCED" == "1" ]] && return $RVAL || exit $RVAL
:
else
handle_args --repl
fi
Expand Down Expand Up @@ -291,7 +301,7 @@ fi

# If PYTHONPATH has changed, echo the new value
if [[ "$PYTHONPATH" != "$initial_pythonpath" ]]; then
echo ";; Updated PYTHONPATH: $PYTHONPATH"
: #echo ";; Updated PYTHONPATH: $PYTHONPATH"
fi

export RUST_BACKTRACE=full
Expand All @@ -303,12 +313,13 @@ pl_directory="metta_vspace/pyswip"

# Initialize a flag to check if any file is newer or if reference file is missing
should_compile=0
never_compile=0

if [[ "1" == "2" ]]; then
if [[ $never_compile -eq 0 ]]; then
# Reference file
reference_file=$(find . -maxdepth 1 -type f -name "Sav.MeTTaLog*" -not -name "*.*" -printf "%T@ %p\n" | sort -k1,1nr | head -n 1 | cut -f2- -d" ")
if [[ -z "$reference_file" ]]; then
reference_file="Sav.MeTTaLog"
reference_file="./Sav.MeTTaLog"
fi

# Check if Sav.MeTTaLog exists
Expand All @@ -335,30 +346,31 @@ fi

# If any newer file found or reference file missing, call the compiler
if [[ $should_compile -eq 1 ]]; then
if [[ -f "$reference_file" ]]; then
echo "Calling compiler from $reference_file..."
swipl -x $reference_file -g qsave_program -g halt
else
#if [[ -f "$reference_file" ]]; then
# echo "Calling compiler from $reference_file..."
# swipl -x $reference_file -g qsave_program -g halt
#else
rm -f $reference_file
echo "Calling compiler..."
swipl -l metta_vspace/pyswip/metta_interp.pl -g qcompile_mettalog
fi
#fi
fi

reference_file=$(find . -maxdepth 1 -type f -name "Sav.MeTTaLog*" -not -name "*.*" -printf "%T@ %p\n" | sort -k1,1nr | head -n 1 | cut -f2- -d" ")
if [[ -z "$reference_file" ]]; then
reference_file="Sav.MeTTaLog"
reference_file="./Sav.MeTTaLog"
fi

if [[ -f "$reference_file" ]]; then
MLOG="$reference_file"
#MLOG="swipl -x $reference_file"
MLOG="$reference_file --"
MLOG="swipl -x $reference_file ${SWI_OPTIONS[*]} --"
MLOG="swipl ${SWI_OPTIONS[*]} -l $METTALOG_DIR/metta_vspace/$PYSWIP_VERSION/metta_interp.pl --"
else
MLOG="swipl ${SWI_OPTIONS[*]} -l $METTALOG_DIR/metta_vspace/$PYSWIP_VERSION/metta_interp.pl --"
fi

fi

MLOG="swipl ${SWI_OPTIONS[*]} -l $METTALOG_DIR/metta_vspace/$PYSWIP_VERSION/metta_interp.pl --"

METTA_CMD="$MLOG --python=$python_flag ${OTHER_OPTIONS[*]}"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The Candidate Elimination algorithm is a conceptual learning algorithm that incr
- Build [Hyperon Experimental](https://github.com/trueagi-io/hyperon-experimental).
- Install PySWIP using:
```
pip install pyswip
pip install git+https://github.com/logicmoo/pyswip.git
```

### :toolbox: Installation
Expand Down
25 changes: 25 additions & 0 deletions examples/.bash_history
Original file line number Diff line number Diff line change
Expand Up @@ -505,3 +505,28 @@ mv override-compat/hyperon-pln~ override-compat/hyperon-pln
ls override-compat/hyperon-pln/
ls override-compat/hyperon-pln/metta/
find override-compat/hyperon-pln/metta/
cp -a examples examples-saved
cd examples
git status .
git restore --source=main '*.answers'
git status .
cls
git status .
git checkout compat/hyperon-pln/metta/common/*.answers
\cp -a ../examples-saved/* .
ls
git status .
cat compat/hyperon-pln/metta/common/MaybeTest.metta.answers
cd add *.answers
git add *.answers
git status .
git add compat/hyperon-pln/metta/synthesis/experiments/synthesize-via-unify-test-longer.metta
git add compat/hyperon-pln/metta/synthesis/experiments/synthesize-via-unify-test-longer.metta.answers
git status .
ls override-compat/hyperon-miner-old/match/
git checkout override-compat/hyperon-miner-old/match/
git status .
git restore override-compat/hyperon-miner-old/match/MinerMatch.metta
git restore override-compat/hyperon-miner-old/match/MinerMatch.metta
git add .
git status .
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
metta
metta-repl
metta-not-repl
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
[()]
[()]
[()]
0.13user 0.03system 0:00.16elapsed 100%CPU (0avgtext+0avgdata 33156maxresident)k
0inputs+0outputs (0major+3459minor)pagefaults 0swaps
0.13user 0.01system 0:00.15elapsed 99%CPU (0avgtext+0avgdata 33104maxresident)k
0inputs+0outputs (0major+3507minor)pagefaults 0swaps
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[()]
0.12user 0.01system 0:00.13elapsed 99%CPU (0avgtext+0avgdata 33152maxresident)k
0inputs+0outputs (0major+3455minor)pagefaults 0swaps
0.10user 0.01system 0:00.11elapsed 100%CPU (0avgtext+0avgdata 32912maxresident)k
0inputs+0outputs (0major+3483minor)pagefaults 0swaps
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
[()]
[()]
[()]
0.12user 0.00system 0:00.13elapsed 100%CPU (0avgtext+0avgdata 32728maxresident)k
0inputs+0outputs (0major+3449minor)pagefaults 0swaps
0.11user 0.01system 0:00.13elapsed 100%CPU (0avgtext+0avgdata 33356maxresident)k
0inputs+0outputs (0major+3516minor)pagefaults 0swaps
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
[()]
[()]
[()]
0.13user 0.01system 0:00.14elapsed 100%CPU (0avgtext+0avgdata 32940maxresident)k
0inputs+0outputs (0major+3454minor)pagefaults 0swaps
0.10user 0.02system 0:00.12elapsed 99%CPU (0avgtext+0avgdata 33084maxresident)k
0inputs+0outputs (0major+3484minor)pagefaults 0swaps
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
[()]
[()]
[()]
0.15user 0.00system 0:00.16elapsed 99%CPU (0avgtext+0avgdata 33108maxresident)k
0inputs+0outputs (0major+3461minor)pagefaults 0swaps
0.13user 0.00system 0:00.14elapsed 99%CPU (0avgtext+0avgdata 33044maxresident)k
0inputs+0outputs (0major+3506minor)pagefaults 0swaps
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
[()]
[()]
[()]
0.14user 0.03system 0:00.17elapsed 100%CPU (0avgtext+0avgdata 33152maxresident)k
0inputs+0outputs (0major+3513minor)pagefaults 0swaps
0.15user 0.00system 0:00.16elapsed 99%CPU (0avgtext+0avgdata 33388maxresident)k
0inputs+0outputs (0major+3544minor)pagefaults 0swaps
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[()]
[()]
[()]
0.12user 0.00system 0:00.12elapsed 100%CPU (0avgtext+0avgdata 32780maxresident)k
0inputs+0outputs (0major+3453minor)pagefaults 0swaps
0.10user 0.01system 0:00.12elapsed 100%CPU (0avgtext+0avgdata 32924maxresident)k
0inputs+0outputs (0major+3482minor)pagefaults 0swaps
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
[()]
[()]
[()]
0.21user 0.01system 0:00.23elapsed 99%CPU (0avgtext+0avgdata 33268maxresident)k
0inputs+0outputs (0major+3499minor)pagefaults 0swaps
0.22user 0.01system 0:00.23elapsed 100%CPU (0avgtext+0avgdata 33284maxresident)k
0inputs+0outputs (0major+3526minor)pagefaults 0swaps
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[]
[]
[]
[]
[]
[]
[]
0.13user 0.00system 0:00.14elapsed 100%CPU (0avgtext+0avgdata 28084maxresident)k
0inputs+0outputs (0major+3404minor)pagefaults 0swaps
[()]
[()]
[()]
[()]
[()]
[()]
[()]
0.13user 0.01system 0:00.15elapsed 99%CPU (0avgtext+0avgdata 33640maxresident)k
0inputs+0outputs (0major+3578minor)pagefaults 0swaps
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[]
[]
[]
[]
[]
0.22user 0.01system 0:00.23elapsed 99%CPU (0avgtext+0avgdata 27836maxresident)k
0inputs+0outputs (0major+3374minor)pagefaults 0swaps
[()]
[()]
[()]
[()]
[()]
0.33user 0.02system 0:00.35elapsed 100%CPU (0avgtext+0avgdata 33660maxresident)k
0inputs+0outputs (0major+3658minor)pagefaults 0swaps
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
0.12user 0.01system 0:00.14elapsed 100%CPU (0avgtext+0avgdata 27436maxresident)k
0inputs+0outputs (0major+3299minor)pagefaults 0swaps
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
0.20user 0.01system 0:00.22elapsed 99%CPU (0avgtext+0avgdata 33252maxresident)k
0inputs+0outputs (0major+3517minor)pagefaults 0swaps
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
0.39user 0.01system 0:00.41elapsed 99%CPU (0avgtext+0avgdata 28388maxresident)k
0inputs+0outputs (0major+3414minor)pagefaults 0swaps
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
[()]
0.77user 0.00system 0:00.78elapsed 99%CPU (0avgtext+0avgdata 34076maxresident)k
1008inputs+0outputs (5major+3639minor)pagefaults 0swaps
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[]
[]
[]
[]
[]
[]
[]
0.12user 0.00system 0:00.13elapsed 99%CPU (0avgtext+0avgdata 27584maxresident)k
0inputs+0outputs (0major+3306minor)pagefaults 0swaps
[()]
[()]
[()]
[()]
[()]
[()]
[()]
0.15user 0.01system 0:00.17elapsed 99%CPU (0avgtext+0avgdata 33308maxresident)k
0inputs+0outputs (0major+3519minor)pagefaults 0swaps
Loading

0 comments on commit 5557af7

Please sign in to comment.