def runTest(self):
        """
        test the function that returns tagged labels from a given text
        """
        from flankers.textsemantics import find_related_concepts

        for i, t in enumerate(self.test1):
            results = find_related_concepts(t)
            print i, results
            # print True, name and the mean of the rho of the term in relation with the scopes
            if i == 0:
                expected = {
                    'electric power units (electrical design)',
                    'precision time and time interval (ptti)',
                    'electric power units (aircraft)',
                    'auxiliary power units (apu) (aircraft)',
                    'electric power units (spacecraft)',
                    'manned maneuvering units',
                    'auxiliary power units (apu) (spacecraft)',
                    'extravehicular activity (eva) (operations)',
                    'extravehicular activity (eva) (equipment)',
                    'inertial sensors and measurement units (spacecraft)',
                    'inertial sensors and measurement units (aircraft)',
                    'extravehicular activity (physiological effects)'
                }
                assert results == expected
            elif i == 1:
                expected = {
                    'robotics (hardware)', 'asteroids (observation)',
                    'robotics', 'extrasolar planets (observation)',
                    'snow and ice observations',
                    'remote manipulator arms (robotics)',
                    'moons (observation)', 'binaries (observation)',
                    'quasars (observation)', 'novae (observation)',
                    'celestial bodies (observation)', 'manned spacecraft',
                    'nebulae (observation)', 'black holes (observation)',
                    'manned orbital laboratories', 'supernovae (observation)',
                    'meteoroids (observation)',
                    'celestial motion (observation)',
                    'manned lunar exploration',
                    'histories of aeronautics and space programs',
                    'comets (observation)', 'manned planetary exploration',
                    'manned maneuvering units',
                    'appropriations hearings (nasa)',
                    'star trackers (observation)', 'pulsars (observation)',
                    'stars (observation)', 'galaxies (observation)',
                    'space programs', 'legal liability of manned space flight',
                    'meteors (observation)', 'scene analysis (robotics)',
                    'rendezvous guidance',
                    'manned flights (space exploration)',
                    'natural satellites (observation)',
                    'teleoperators (robotics)',
                    'observation of celestial bodies'
                }
                assert results == expected
            elif i == 2:
                expected = set([])
                assert results == expected
            else:
                assert False
 def execute_task(self, *args):
     item, key = args
     from flankers.textsemantics import find_related_concepts
     if not (item.title == '' and item.abstract == ''):
         # if item is not a media or a link from Twitter
         # it is or a feed or a tweet
         text = item.abstract if len(item.abstract) != 0 else item.title
         labels = find_related_concepts(text)
         for l in labels:
             if Indexer.query().filter(Indexer.webres == key).count() == 0:
                 index = Indexer(keyword=l.strip(), webres=key)
                 index.put()
                 print "indexing stored: " + item.url + ">" + l
Example #3
0
 def execute_task(self, *args):
     item, key = args
     from flankers.textsemantics import find_related_concepts
     if not (item.title == '' and item.abstract == ''):
         # if item is not a media or a link from Twitter
         # it is or a feed or a tweet
         text = item.abstract if len(item.abstract) != 0 else item.title
         labels = find_related_concepts(text)
         for l in labels:
             if Indexer.query().filter(Indexer.webres == key).count() == 0:
                 index = Indexer(keyword=l.strip(), webres=key)
                 index.put()
                 print "indexing stored: " + item.url + ">" + l
    def runTest(self):
        """
        test the function that returns tagged labels from a given text
        """
        from flankers.textsemantics import find_related_concepts

        for i, t in enumerate(self.test1):
            results = find_related_concepts(t)
            print i, results
            # print True, name and the mean of the rho of the term in relation with the scopes
            if i == 0:
                expected = {'electric power units (electrical design)', 'precision time and time interval (ptti)',
                            'electric power units (aircraft)', 'auxiliary power units (apu) (aircraft)',
                            'electric power units (spacecraft)', 'manned maneuvering units',
                            'auxiliary power units (apu) (spacecraft)', 'extravehicular activity (eva) (operations)',
                            'extravehicular activity (eva) (equipment)',
                            'inertial sensors and measurement units (spacecraft)',
                            'inertial sensors and measurement units (aircraft)',
                            'extravehicular activity (physiological effects)'}
                assert results == expected
            elif i == 1:
                expected = {'robotics (hardware)', 'asteroids (observation)', 'robotics',
                            'extrasolar planets (observation)', 'snow and ice observations',
                            'remote manipulator arms (robotics)', 'moons (observation)', 'binaries (observation)',
                            'quasars (observation)', 'novae (observation)', 'celestial bodies (observation)',
                            'manned spacecraft', 'nebulae (observation)', 'black holes (observation)',
                            'manned orbital laboratories', 'supernovae (observation)', 'meteoroids (observation)',
                            'celestial motion (observation)', 'manned lunar exploration',
                            'histories of aeronautics and space programs', 'comets (observation)',
                            'manned planetary exploration', 'manned maneuvering units',
                            'appropriations hearings (nasa)', 'star trackers (observation)', 'pulsars (observation)',
                            'stars (observation)', 'galaxies (observation)', 'space programs',
                            'legal liability of manned space flight', 'meteors (observation)',
                            'scene analysis (robotics)', 'rendezvous guidance', 'manned flights (space exploration)',
                            'natural satellites (observation)', 'teleoperators (robotics)',
                            'observation of celestial bodies'}
                assert results == expected
            elif i == 2:
                expected = set([])
                assert results == expected
            else:
                assert False