import unittest
from tqdm import tqdm
from loguru import logger
from nlps_extraction.tasks.extraction import (
    FixRedirectsTask,
    XMLParserTask,
    FixSnippetsTask,
    GetCategoriesTask,
    CurateTitlesTask,
    GetDefinitionsTask,
)
import random


class GetDefinitionsTest(unittest.TestCase):
    def test_get_definitions(self):
        parser = XMLParserTask()
        xml_file = parser.run()
        fix_redirect = FixRedirectsTask()
        fixed_result = fix_redirect.run(xml_file)
        fix_snippets = FixSnippetsTask()
        fixed_snippets = fix_snippets.run(fixed_result)
        get_categories = GetCategoriesTask()
        out_entries, definitions_category, top_categories = get_categories.run(
            fixed_snippets
        )
        curate_titles = CurateTitlesTask()
        curate_results = curate_titles.run(out_entries)
        get_definitions = GetDefinitionsTask()
        definitions, others = get_definitions.run(curate_results, definitions_category)
