"""
Data definitions for smokes_example.py

The full definitions are in this Scheme file:
  https://github.com/opencog/test-datasets/blob/master/pln/tuffy/smokes/smokes.scm
They are redefined in Python format here for testing, due to this bug that
prevents importing Scheme files without a running cogserver:
  https://github.com/opencog/opencog/issues/530
"""

__author__ = 'Cosmo Harrigan'

from opencog.atomspace import AtomSpace, TruthValue, types

atomspace = AtomSpace()

# Basic variable definitions
X = atomspace.add_node(types.VariableNode, "$X")
lX = atomspace.add_link(types.ListLink, [X])

Y = atomspace.add_node(types.VariableNode, "$Y")
lY = atomspace.add_link(types.ListLink, [Y])

X_Y = atomspace.add_link(types.ListLink, [X, Y])

full_confidence = TruthValue().confidence_to_count(1)
crisp_true = TruthValue(1, full_confidence)

# Anna smokes.
Anna = atomspace.add_node(types.ConceptNode, "Anna")
smokes = atomspace.add_node(types.PredicateNode, "smokes")
atomspace.add_link(types.EvaluationLink,
                   [smokes, atomspace.add_link(types.ListLink, [Anna])],
                   crisp_true)

# Edward smokes.
Edward = atomspace.add_node(types.ConceptNode, "Edward")
smokes = atomspace.add_node(types.PredicateNode, "smokes")
atomspace.add_link(types.EvaluationLink,
                   [smokes, atomspace.add_link(types.ListLink, [Edward])],
                   crisp_true)

# If X smokes, then X has cancer.
cancer = atomspace.add_node(types.PredicateNode, "cancer")
smokes_X = atomspace.add_link(types.EvaluationLink, [smokes, lX])
cancer_X = atomspace.add_link(types.EvaluationLink, [cancer, lX])

atomspace.add_link(types.ImplicationLink,
                   [smokes_X, cancer_X],
                   TruthValue(0.5, full_confidence))

# In the case that X and Y are friends, if X smokes then so does Y.
"""
(ImplicationLink (stv 0.4 1.0)
    (EvaluationLink (stv 1.0 0.0)
        friends
        (ListLink
            (VariableNode "$X")
            (VariableNode "$Y")))
    (ImplicationLink
        (EvaluationLink (stv 1.0 0.0)
            smokes
            (ListLink
                (VariableNode "$X")))
        (EvaluationLink (stv 1.0 0.0)
            smokes
            (ListLink
                (VariableNode "$Y")))))
"""
friends = atomspace.add_node(types.PredicateNode, "friends")
friends_X_Y = atomspace.add_link(types.EvaluationLink, [friends, X_Y])

smokes_Y = atomspace.add_link(types.EvaluationLink, [smokes, lY])

implication_smokes_X_smokes_Y = atomspace.add_link(
    types.ImplicationLink, [smokes_X, smokes_Y])

atomspace.add_link(types.ImplicationLink,
                   [friends_X_Y, implication_smokes_X_smokes_Y],
                   TruthValue(0.4, full_confidence))

# Anna is friends with Bob.
Bob = atomspace.add_node(types.ConceptNode, "Bob")
atomspace.add_link(
    types.EvaluationLink,
    [friends, atomspace.add_link(types.ListLink, [Anna, Bob])], crisp_true)

# Edward is friends with Frank.
Frank = atomspace.add_node(types.ConceptNode, "Frank")
atomspace.add_link(
    types.EvaluationLink,
    [friends, atomspace.add_link(types.ListLink, [Edward, Frank])], crisp_true)

@@ -1,9 +1,26 @@
 %22%22%22%0A
-D
+Python-formatted d
 ata 
@@ -58,20 +58,32 @@
 py%0A%0AThe 
-full
+Scheme-formatted
  definit
@@ -99,23 +99,16 @@
 in this 
-Scheme 
 file:%0A  
@@ -201,18 +201,21 @@
 are 
-re
+also 
 defined 
 in P
@@ -210,16 +210,21 @@
 defined 
+here 
 in Pytho
@@ -232,21 +232,16 @@
  format 
-here 
 for test
@@ -247,139 +247,9 @@
 ting
-, due to this bug that%0Aprevents importing Scheme files without a running cogserver:%0A  https://github.com/opencog/opencog/issues/530
+.
 %0A%22%22%22
@@ -1085,67 +1085,8 @@
 d%22)%0A
-smokes = atomspace.add_node(types.PredicateNode, %22smokes%22)%0A
 atom
@@ -1570,16 +1570,19 @@
 Value(0.
+622
 5, full_
@@ -1667,438 +1667,8 @@
  Y.%0A
-%22%22%22%0A(ImplicationLink (stv 0.4 1.0)%0A    (EvaluationLink (stv 1.0 0.0)%0A        friends%0A        (ListLink%0A            (VariableNode %22$X%22)%0A            (VariableNode %22$Y%22)))%0A    (ImplicationLink%0A        (EvaluationLink (stv 1.0 0.0)%0A            smokes%0A            (ListLink%0A                (VariableNode %22$X%22)))%0A        (EvaluationLink (stv 1.0 0.0)%0A            smokes%0A            (ListLink%0A                (VariableNode %22$Y%22)))))%0A%22%22%22%0A
 frie
@@ -2108,9 +2108,12 @@
 e(0.
-4
+5987
 , fu
@@ -2323,32 +2323,183 @@
 %5D, crisp_true)%0A%0A
+# Anna is friends with Bob.%0Aatomspace.add_link(%0A    types.EvaluationLink,%0A    %5Bfriends, atomspace.add_link(types.ListLink, %5BBob, Anna%5D)%5D, crisp_true)%0A%0A
 # Edward is frie

Update mln smokes data definitions