work in progress: automatic classification

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2072 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2007-09-27 06:06:24 +00:00
parent bf8a641654
commit 1e0b976929
3 changed files with 42 additions and 4 deletions

View file

@ -96,11 +96,35 @@ that may be identified as being candidates for classification.
... title=u'Institution', conceptType=concepts['type'])
>>> cust_im = addObject(concepts, Concept, 'im_editors',
... title=u'im Editors', conceptType=tInstitution)
>>> cust_mc = addObject(concepts, Concept, 'mc_consulting',
... title=u'MC Management Consulting', conceptType=tInstitution)
>>> tDoctype = addObject(concepts, Concept, 'doctype',
... title=u'Document Type', conceptType=concepts['type'])
>>> dt_note = addObject(concepts, Concept, 'dt_note',
... title=u'Note', conceptType=tDoctype)
>>> dt_contract = addObject(concepts, Concept, 'dt_contract',
... title=u'Contract', conceptType=tDoctype)
>>> tPerson = concepts['person']
>>> webbg = addObject(concepts, Concept, 'webbg',
... title=u'Gerald Webb', conceptType=tPerson)
>>> smitha = addObject(concepts, Concept, 'smitha',
... title=u'Angelina Smith', conceptType=tPerson)
>>> watersj = addObject(concepts, Concept, 'watersj',
... title=u'Jerry Waters', conceptType=tPerson)
>>> millerj = addObject(concepts, Concept, 'millerj',
... title=u'Jeannie Miller', conceptType=tPerson)
>>> t.indexAll(concepts, resources)
>>> from zope.app.catalog.interfaces import ICatalog
>>> cat = component.getUtility(ICatalog)
>>> #list(cat.searchResults(loops_text='webbg'))
>>> statements = analyzer.extractStatements(infoSet, classifier)
>>> len(statements)
1
2
So we are now ready to have the whole stuff run in one call.

View file

@ -30,6 +30,7 @@ from cybertools.organize.interfaces import IPerson
from cybertools.typology.interfaces import IType
from loops.classifier.base import Analyzer
from loops.classifier.base import Statement
from loops.common import adapted
class SampleAnalyzer(Analyzer):
@ -58,12 +59,21 @@ class SampleAnalyzer(Analyzer):
def handleEmployee(self, name, classifier):
result = []
#print 'employee', name
candidates = self.findConcepts(name)
cm = self.getConceptManager(classifier)
for c in candidates:
ctype = IType(c)
if ctype.typeInterface == IPerson:
result.append(Statement(c))
return result
def handleOwner(self, name, classifier):
result = []
#print 'owner', name
candidates = self.findConcepts(name)
cm = self.getConceptManager(classifier)
for c in candidates:
if IPerson.providedBy(adapted(c)):
result.append(Statement(c))
return result
def handleDoctype(self, name, classifier):

View file

@ -19,11 +19,13 @@ from loops.classifier.interfaces import IClassifier, IAnalyzer
from loops.common import adapted
from loops.concept import Concept
from loops.resource import Resource, ExternalFileAdapter
from loops.interfaces import IIndexAttributes, IExternalFile
from loops.interfaces import IConcept, IIndexAttributes, IExternalFile
from loops.integrator.collection import DirectoryCollectionProvider
from loops.integrator.collection import ExternalCollectionAdapter
from loops.integrator.interfaces import IExternalCollection, IExternalCollectionProvider
from loops.knowledge.setup import SetupManager as KnowledgeSetupManager
from loops.knowledge.knowledge import Person
from loops.knowledge.interfaces import IPerson
from loops.setup import SetupManager, addAndConfigureObject
from loops.tests.setup import TestSite as BaseTestSite
@ -68,6 +70,8 @@ class TestSite(BaseTestSite):
title=u'External Collection', conceptType=tType,
typeInterface=IExternalCollection)
component.provideAdapter(Person, (IConcept,), IPerson)
self.indexAll(concepts, resources)
return concepts, resources, views