OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
atom_type_names.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 #
3 # atom_type_names.py
4 #
5 """
6 Example of how to obtain atom type names and atom type IDs in Python
7 """
8 
9 __author__ = 'Cosmo Harrigan'
10 
11 from opencog.atomspace import AtomSpace, TruthValue, types, get_type_name
12 from opencog.scheme_wrapper import load_scm, scheme_eval, scheme_eval_h, __init__
13 
14 atomspace = AtomSpace()
15 __init__(atomspace)
16 
17 data = ["opencog/atomspace/core_types.scm",
18  "opencog/scm/utilities.scm"]
19 
20 for item in data:
21  load_scm(atomspace, item)
22 
23 atom = atomspace.add(types.ConceptNode, "Frog #1")
24 
25 # To get one type name
26 print get_type_name(3) + '\n'
27 
28 # To get one atom's type name
29 print get_type_name(atom.type) + '\n'
30 
31 # Get a list of all possible type names and numbers
32 for key, value in sorted(types.__dict__.iteritems()):
33  if '__' not in key:
34  print key, value