brain: fixes (zope.interface.implementer); + text: improvements
This commit is contained in:
parent
06682d2a5c
commit
bd631677d6
5 changed files with 18 additions and 81 deletions
|
@ -1,38 +1,18 @@
|
||||||
#
|
# cybertools.brain.neuron
|
||||||
# Copyright (c) 2006 Helmut Merz helmutm@cy55.de
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# 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 General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
""" A simple basic implementation of Neuron and Synapsis.
|
||||||
A simple basic implementation of Neuron and Synapsis.
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.interface import implements
|
from zope.interface import implementer
|
||||||
from cybertools.brain.interfaces import INeuron, ISynapsis
|
from cybertools.brain.interfaces import INeuron, ISynapsis
|
||||||
from cybertools.brain.state import State, Transition
|
from cybertools.brain.state import State, Transition
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(ISynapsis)
|
||||||
class Synapsis(object):
|
class Synapsis(object):
|
||||||
""" A synapsis connects two neurons.
|
""" A synapsis connects two neurons.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
implements(ISynapsis)
|
|
||||||
|
|
||||||
def __init__(self, sender, receiver):
|
def __init__(self, sender, receiver):
|
||||||
self.sender = sender
|
self.sender = sender
|
||||||
sender.receivers.append(self)
|
sender.receivers.append(self)
|
||||||
|
@ -46,10 +26,9 @@ class Synapsis(object):
|
||||||
receiver.notify(session)
|
receiver.notify(session)
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(INeuron)
|
||||||
class Neuron(object):
|
class Neuron(object):
|
||||||
|
|
||||||
implements(INeuron)
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.senders = []
|
self.senders = []
|
||||||
self.receivers = []
|
self.receivers = []
|
||||||
|
|
|
@ -1,35 +1,15 @@
|
||||||
#
|
# cybertools.brain.session
|
||||||
# Copyright (c) 2006 Helmut Merz helmutm@cy55.de
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# 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 General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
""" Transaction management.
|
||||||
Transaction management.
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.interface import implements
|
from zope.interface import implementer
|
||||||
from cybertools.brain.interfaces import ISession
|
from cybertools.brain.interfaces import ISession
|
||||||
|
|
||||||
|
|
||||||
|
implementer(ISession)
|
||||||
class Session(object):
|
class Session(object):
|
||||||
|
|
||||||
implements(ISession)
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.states = {}
|
self.states = {}
|
||||||
|
|
||||||
|
|
|
@ -1,37 +1,17 @@
|
||||||
#
|
# cybertools.brain.state
|
||||||
# Copyright (c) 2006 Helmut Merz helmutm@cy55.de
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# 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 General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
""" Base classes for state and state manipulations using a float-based state.
|
||||||
Base classes for state and state manipulations using a float-based state.
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.interface import implements
|
from zope.interface import implementer
|
||||||
from cybertools.brain.interfaces import IState, ITransition
|
from cybertools.brain.interfaces import IState, ITransition
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(IState)
|
||||||
class State(object):
|
class State(object):
|
||||||
""" The state of a neuron.
|
""" The state of a neuron.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
implements(IState)
|
|
||||||
|
|
||||||
def __init__(self, value=0.0):
|
def __init__(self, value=0.0):
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
|
@ -39,10 +19,9 @@ class State(object):
|
||||||
return '<State %0.1f>' % self.value
|
return '<State %0.1f>' % self.value
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(ITransition)
|
||||||
class Transition(object):
|
class Transition(object):
|
||||||
|
|
||||||
implements(ITransition)
|
|
||||||
|
|
||||||
def __init__(self, synapsis, factor=1.0):
|
def __init__(self, synapsis, factor=1.0):
|
||||||
self.synapsis = synapsis
|
self.synapsis = synapsis
|
||||||
self.factor = factor
|
self.factor = factor
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
Text Transformations, e.g. for Full-text Indexing
|
Text Transformations, e.g. for Full-text Indexing
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
($Id$)
|
|
||||||
|
|
||||||
If a converter program needed is not available we want to put a warning
|
If a converter program needed is not available we want to put a warning
|
||||||
into Zope's server log; in order to be able to test this we register
|
into Zope's server log; in order to be able to test this we register
|
||||||
a log handler for testing:
|
a log handler for testing:
|
||||||
|
|
|
@ -5,21 +5,22 @@ Tests for the 'cybertools.text' package.
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
#sys.path = [p for p in sys.path if p != '']
|
#sys.path = [p for p in sys.path if p != '']
|
||||||
sys.path = sys.path[2:]
|
sys.path = sys.path[2:] # avoid import cycle with bs4 when importing html
|
||||||
print(sys.path)
|
#print(sys.path)
|
||||||
|
|
||||||
import unittest, doctest
|
import unittest, doctest
|
||||||
import warnings
|
import warnings
|
||||||
from cybertools.text import pdf
|
from cybertools.text import pdf
|
||||||
from cybertools.text.html import htmlToText
|
from cybertools.text.html import htmlToText
|
||||||
|
|
||||||
warnings.filterwarnings('ignore', category=ResourceWarning)
|
|
||||||
|
|
||||||
|
|
||||||
class Test(unittest.TestCase):
|
class Test(unittest.TestCase):
|
||||||
"Basic tests for the text package."
|
"Basic tests for the text package."
|
||||||
|
|
||||||
def testBasicStuff(self):
|
def testBasicStuff(self):
|
||||||
|
warnings.filterwarnings('ignore', category=ResourceWarning)
|
||||||
|
warnings.filterwarnings('ignore', category=DeprecationWarning)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue