Projects STRLCPY Maryam Commits 84d45be6
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    maryam/modules/iris/iris_cluster.py
     1 +"""
     2 +OWASP Maryam!
     3 +This program is free software: you can redistribute it and/or modify
     4 +it under the terms of the GNU General Public License as published by
     5 +the Free Software Foundation, either version 3 of the License, or
     6 +any later version.
     7 +This program is distributed in the hope that it will be useful,
     8 +but WITHOUT ANY WARRANTY; without even the implied warranty of
     9 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     10 +GNU General Public License for more details.
     11 +You should have received a copy of the GNU General Public License
     12 +along with this program. If not, see <http://www.gnu.org/licenses/>.
     13 +"""
     14 + 
     15 +meta = {
     16 + 'name': 'Iris_Cluster',
     17 + 'author': 'Shaad',
     18 + 'version': '0.1',
     19 + 'description': 'Get Iris Search result and clustered results for your query',
     20 + 'required': ('Same as Iris and Cluster module'),
     21 + 'options': (
     22 + ('query', None, True, 'Query string', '-q', 'store', str),
     23 + ),
     24 + 'examples': ('iris_cluster -q <QUERY>')
     25 +}
     26 + 
     27 + 
     28 +def module_api(self):
     29 + query = self.options['query']
     30 + output_option_value = self.options['output']
     31 + output = {}
     32 + 
     33 + # Computing iris search result
     34 + self._mode = 'api_mode'
     35 + iris_search_result = self.opt_proc('iris', args=f'-q "{query}" --api', output='web_api')
     36 + output['iris_search_result'] = iris_search_result
     37 + 
     38 + # Computing cluster results
     39 + clusterer = self.cluster(iris_search_result)
     40 + output['cluster_result'] = {'json': clusterer.perform_clustering()}
     41 + 
     42 + # Resetting options for iris_search_module
     43 + self.options = {}
     44 + self.options['query'] = query
     45 + self.options['output'] = output_option_value
     46 + 
     47 + self.save_gather(output, 'iris/iris_cluster', query, output=self.options['output'])
     48 +
     49 + return output
     50 + 
     51 + 
     52 +def module_run(self):
     53 + output = module_api(self)
     54 + iris_search_result = output['iris_search_result']
     55 + cluster_result = output['cluster_result']['json']
     56 + 
     57 + print('IRIS SEARCH RESULT: ')
     58 + self.search_engine_results(iris_search_result)
     59 + 
     60 + print('\n\nCLUSTER RESULT: ')
     61 + for index, title in enumerate(cluster_result):
     62 + print('\n')
     63 + print(f"CLUSTER {index+1}")
     64 + print(f"TITLE: {title}")
     65 + print(' '+'\n '.join(cluster_result[title]))
     66 + 
Please wait...
Page is in error, reload to recover