<commit_before>#
# face_atomic.py - Send face data to the cogserver/atomspace.
# Copyright (C) 2015  <NAME>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License v3 as
# published by the Free Software Foundation and including the exceptions
# at http://opencog.org/wiki/Licenses
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to:
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


from opencog.atomspace import AtomSpace, TruthValue
from opencog.type_constructors import *

from opencog.cogserver import get_server_atomspace


# The code here is a quick, cheap hack to place information about
# visible faces into the cogserver atomspace.  There ae several
# different ways we could implement this:
#
# A) Open a socket to the cogserver, send atoms through the socket.
# B) Run inside the cogserver, and place atoms in the atomspace
#    directly.
#
# At the moment, for convenience, B) is implemented. However, A better
# long term choice might be design A).


class FaceAtomic:

	def __init__(self):
		# The atomspace where everything will live.
		self.asp = get_server_atomspace()
		set_type_ctor_atomspace(self.asp)

	# Add a face to the atomspace.
	def add_face_to_atomspace(self, faceid):
		self.define_face(faceid)
		print "Defined face in atomspace: ", faceid

	# Remove a face from the atomspace.
	def remove_face_from_atomspace(self, faceid):

		# AtomSpace remove takes handle as an argument.
		self.asp.remove(self.define_face(faceid))
		print "Removed face from atomspace: ", faceid
		# XXX TODO Remove the NumberNode as well, if no
		# one is using it.

	# Define a handle the represent a visible face.
	# Return the handle.
	def define_face(self, faceid):
		face = EvaluationLink(
			ConceptNode("visible face"),
			ListLink(
				NumberNode(str(faceid))))
		face = atom.h
		return face<commit_msg>fix typo<commit_after>#
# face_atomic.py - Send face data to the cogserver/atomspace.
# Copyright (C) 2015  <NAME>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License v3 as
# published by the Free Software Foundation and including the exceptions
# at http://opencog.org/wiki/Licenses
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to:
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


from opencog.atomspace import AtomSpace, TruthValue
from opencog.type_constructors import *

from opencog.cogserver import get_server_atomspace


# The code here is a quick, cheap hack to place information about
# visible faces into the cogserver atomspace.  There ae several
# different ways we could implement this:
#
# A) Open a socket to the cogserver, send atoms through the socket.
# B) Run inside the cogserver, and place atoms in the atomspace
#    directly.
#
# At the moment, for convenience, B) is implemented. However, A better
# long term choice might be design A).


class FaceAtomic:

	def __init__(self):
		# The atomspace where everything will live.
		self.asp = get_server_atomspace()
		set_type_ctor_atomspace(self.asp)

	# Add a face to the atomspace.
	def add_face_to_atomspace(self, faceid):
		self.define_face(faceid)
		print "Defined face in atomspace: ", faceid

	# Remove a face from the atomspace.
	def remove_face_from_atomspace(self, faceid):

		# AtomSpace remove takes handle as an argument.
		self.asp.remove(self.define_face(faceid))
		print "Removed face from atomspace: ", faceid
		# XXX TODO Remove the NumberNode as well, if no
		# one is using it.

	# Define a handle the represent a visible face.
	# Return the handle.
	def define_face(self, faceid):
		face = EvaluationLink(
			ConceptNode("visible face"),
			ListLink(
				NumberNode(str(faceid))))
		return face
{'fraction_non_alphanumeric': 0.06905769659166852, 'fraction_numerical': 0.007128536422365783, 'mean_word_length': 4.2453271028037385, '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': '5977324', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1291, 'n_words': 578}