<commit_before>#! /usr/bin/env python
#
# bindlink.py
#
"""
Example of how to use the pattern matcher.
Based on the following example in the wiki:
http://wiki.opencog.org/w/Pattern_matching#The_Simplified_API
"""

__author__ = '<NAME>'

from opencog.atomspace import AtomSpace
from opencog.scheme_wrapper import scheme_eval, scheme_eval_h

atomspace = AtomSpace()

# Add to scheme's %load-path directory to serach for opencog guile modules
scheme_eval(atomspace, "(add-to-load-path \"/usr/local/share/opencog/scm\")")

# Import opencog modules required for using `cog-execute!` in scheme_eval
scheme_eval(atomspace, "(use-modules (opencog))")
scheme_eval(atomspace, "(use-modules (opencog exec))")

# Define several animals and something of a different type as well
scheme_animals = \
    '''
    (InheritanceLink (ConceptNode "Frog") (ConceptNode "animal"))
    (InheritanceLink (ConceptNode "Zebra") (ConceptNode "animal"))
    (InheritanceLink (ConceptNode "Deer") (ConceptNode "animal"))
    (InheritanceLink (ConceptNode "Spaceship") (ConceptNode "machine"))
    '''
scheme_eval_h(atomspace, scheme_animals)<commit_msg>Remove cruft<commit_after>#! /usr/bin/env python
#
# bindlink.py
#
"""
Example of how to use the pattern matcher.
Based on the following example in the wiki:
http://wiki.opencog.org/w/Pattern_matching#The_Simplified_API
"""

__author__ = '<NAME>'

from opencog.atomspace import AtomSpace
from opencog.scheme_wrapper import scheme_eval, scheme_eval_h

atomspace = AtomSpace()

# Import opencog modules required for using `cog-execute!` in scheme_eval
scheme_eval(atomspace, "(use-modules (opencog))")
scheme_eval(atomspace, "(use-modules (opencog exec))")

# Define several animals and something of a different type as well
scheme_animals = \
    '''
    (InheritanceLink (ConceptNode "Frog") (ConceptNode "animal"))
    (InheritanceLink (ConceptNode "Zebra") (ConceptNode "animal"))
    (InheritanceLink (ConceptNode "Deer") (ConceptNode "animal"))
    (InheritanceLink (ConceptNode "Spaceship") (ConceptNode "machine"))
    '''
scheme_eval_h(atomspace, scheme_animals)
{'fraction_non_alphanumeric': 0.12183468705207835, 'fraction_numerical': 0.0, 'mean_word_length': 5.6900958466453675, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1192199', 'n_tokens_mistral': 711, 'n_tokens_neox': 684, 'n_words': 182}