diff --git a/classifier/README.txt b/classifier/README.txt index c9ccbb7..6654baa 100644 --- a/classifier/README.txt +++ b/classifier/README.txt @@ -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. diff --git a/classifier/sample.py b/classifier/sample.py index 2bbaf9d..18b7f33 100644 --- a/classifier/sample.py +++ b/classifier/sample.py @@ -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): diff --git a/classifier/testsetup.py b/classifier/testsetup.py index f58e98e..6d758b7 100644 --- a/classifier/testsetup.py +++ b/classifier/testsetup.py @@ -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