コード例 #1
0
    def test_is_a(self):
        self.assertTrue(is_a(types.ConceptNode, types.Node))
        self.assertTrue(is_a(types.ConceptNode, types.Atom))

        self.assertTrue(is_a(types.ListLink, types.Link))
        self.assertTrue(is_a(types.ListLink, types.Atom))

        self.assertFalse(is_a(types.Link, types.Node))
コード例 #2
0
ファイル: test_atomspace.py プロジェクト: nko5/atomspace
    def test_is_a(self):
        self.assertTrue(is_a(types.ConceptNode, types.Node))
        self.assertTrue(is_a(types.ConceptNode, types.Atom))

        self.assertTrue(is_a(types.ListLink, types.Link))
        self.assertTrue(is_a(types.ListLink, types.Atom))

        self.assertFalse(is_a(types.Link, types.Node))
コード例 #3
0
ファイル: utils.py プロジェクト: singnet/rocca
def to_python(atom: Atom):
    """Return a Pythonic data representation of an atom"""
    if is_a(atom.type, AT.ListLink):
        # HACK: here I just turn lists into numpy arrays because MineRL expects that
        return np.array([to_python(a) for a in atom.out])
    if is_a(atom.type, AT.NumberNode):
        return float(atom.name)
    return atom.name
コード例 #4
0
ファイル: utils.py プロジェクト: ntoxeg/rocca
def is_sequential_and(atom: Atom) -> bool:
    """Return True iff atom is a sequential and.

    Also for now we use BackSequentialAndLink.

    """

    return is_a(atom.type, get_type("BackSequentialAndLink"))
コード例 #5
0
ファイル: utils.py プロジェクト: opencog/rocca
def is_sequential_and(atom):
    """Return True iff atom is a sequential and.

    Also for now we use AltSequentialAndLink.

    """

    return is_a(atom.type, get_type("AltSequentialAndLink"))
コード例 #6
0
ファイル: utils.py プロジェクト: ntoxeg/rocca
def is_virtual(clause: Atom) -> bool:
    """Return true iff the clause is virtual.

    For instance

    (GreaterThanLink (NumberNode "1") (NumberNode "2"))

    is virtual because it gets evaluated on the fly as opposed to be
    query against the atomspace.

    """

    # TODO: can be simplified with clause.is_a
    return is_a(clause.type, types.VirtualLink)
コード例 #7
0
ファイル: utils.py プロジェクト: ntoxeg/rocca
def is_execution(atom: Atom) -> bool:
    """Return True iff the atom is an ExecutionLink."""

    return is_a(atom.type, types.ExecutionLink)
コード例 #8
0
ファイル: utils.py プロジェクト: ntoxeg/rocca
def is_and(atom: Atom) -> bool:
    """Return True iff the atom is an and link."""

    return is_a(atom.type, types.AndLink)
コード例 #9
0
ファイル: utils.py プロジェクト: ntoxeg/rocca
def is_predictive_implication_scope(atom: Atom) -> bool:
    """Return True iff the atom is a predictive implication scope link."""

    return is_a(atom.type, get_type("BackPredictiveImplicationScopeLink"))
コード例 #10
0
ファイル: utils.py プロジェクト: ntoxeg/rocca
def is_scope(atom: Atom) -> bool:
    """Return True iff the atom is a scope link."""

    return is_a(atom.type, types.ScopeLink)
コード例 #11
0
ファイル: utils.py プロジェクト: ntoxeg/rocca
def is_variable_set(atom: Atom) -> bool:
    """Return True iff the atom is a VariableSet."""

    return is_a(atom.type, types.VariableSet)
コード例 #12
0
ファイル: utils.py プロジェクト: ntoxeg/rocca
def is_variable(atom: Atom) -> bool:
    """Return True iff the atom is a variable node."""

    return is_a(atom.type, types.VariableNode)
コード例 #13
0
ファイル: utils.py プロジェクト: opencog/rocca
def is_predictive_implication(atom):
    """Return True iff the atom is a predictive implication link."""

    return is_a(atom.type, get_type("PredictiveImplicationLink"))
コード例 #14
0
ファイル: is_a.py プロジェクト: tanksha/atomspace
#! /usr/bin/env python
#
# is_a.py
#
"""
A simple example of how to use the nameserver.
"""

from opencog.atomspace import AtomSpace
from opencog.atomspace import get_type, is_a
from opencog.atomspace import types
from opencog.type_constructors import *

a = AtomSpace()

# Tell the type constructors which atomspace to use.
set_default_atomspace(a)

# Is a set unordered
set_is_unordered = is_a(get_type("SetLink"), get_type("UnorderedLink"))
print("Is a set unordered?", set_is_unordered)

# Is A a concept or a predicate?
A = ConceptNode("A")
print("Is A a concept?", is_a(A.type, get_type("ConceptNode")))
print("Is A a predicate?", is_a(A.type, get_type("PredicateNode")))
コード例 #15
0
def is_predictive_implication_scope(atom):
    """Return True iff the atom is a predictive implication scope link."""

    return is_a(atom.type, types.PredictiveImplicationScopeLink)