2022-09-20 14:11:48 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path.append(os.environ['AIL_BIN'])
|
|
|
|
##################################
|
|
|
|
# Import Project packages
|
|
|
|
##################################
|
|
|
|
from modules.abstract_module import AbstractModule
|
|
|
|
from lib.objects.Domains import Domain
|
|
|
|
from lib.objects.Items import Item
|
2022-10-25 14:25:19 +00:00
|
|
|
# from lib.ConfigLoader import ConfigLoader
|
2022-09-20 14:11:48 +00:00
|
|
|
|
|
|
|
class Languages(AbstractModule):
|
|
|
|
"""
|
|
|
|
Languages module for AIL framework
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(Languages, self).__init__()
|
|
|
|
|
|
|
|
# Send module state to logs
|
2023-05-12 13:29:53 +00:00
|
|
|
self.logger.info(f'Module {self.module_name} initialized')
|
2022-09-20 14:11:48 +00:00
|
|
|
|
|
|
|
def compute(self, message):
|
2023-10-11 12:53:12 +00:00
|
|
|
obj = self.get_obj()
|
|
|
|
|
|
|
|
if obj.type == 'item':
|
2023-11-08 10:59:06 +00:00
|
|
|
if obj.is_crawled():
|
|
|
|
domain = Domain(obj.get_domain())
|
|
|
|
for lang in obj.get_languages(min_probability=0.8):
|
2023-10-11 12:53:12 +00:00
|
|
|
domain.add_language(lang.language)
|
2022-09-20 14:11:48 +00:00
|
|
|
|
2022-10-25 14:25:19 +00:00
|
|
|
|
2022-09-20 14:11:48 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
module = Languages()
|
|
|
|
module.run()
|