<commit_before>.. _quickstart:

Quickstart
==========
This page gives a brief introduction to the library.
It assumes you have the library installed,
if you don’t check the :ref:`install` portion.

The code block below showcases the basic usage using the built in support for
PostgreSQL and SQLite3.

.. code-block:: python3

    from pathlib import Path

    from roboragi import Medium, Roboragi, Site

    mal_config = {
        'user': 'MAL User name',
        'password': '<PASSWORD>'
    }
    anilist_config = {
        'id': 'Anilist client id',
        'secret': 'Anilist client secret'
    }


    async def postgres():
        postgres_config = {
            "host": "localhost",
            "port": "5432",
            "user": "postgres",
            "database": "postgres"
        }

        # You can choose how many pages from Anilist
        # and how many entries from MAL
        # to cache at the instance creation.
        robo = await Roboragi.from_postgres(
            mal_config, anilist_config, postgres_config,
            cache_pages=1, cache_mal_entries=30
        )

        # get_data eagerly evaluates all the data
        # and return them in a dict
        saekano = await robo.get_data(
            'Saenai Heroine no Sodatekata', Medium.ANIME
        )
        for site, data in saekano.items():
            print(site, data)

        # yield_data lazily evaluates the data
        # and you can iterate over them as such
        async for site, data in robo.yield_data('New Game!',
                                                Medium.MANGA):
            print(site, data)


    async def sqlite():
        # from_sqlite method accepts a string or a Pathlib Path object.
        sqlite_path = 'path/to/sqlite/database'
        another_path = Path('another/sqlite/path')

        robo = await Roboragi.from_sqlite(
            mal_config, anilist_config, sqlite_path
        )

        # We only want the results from those 2 sites.
        sites = (Site.LNDB, Site.MAL)
        async for site, data in robo.get_data(
            'overlord', Medium.LN, sites):
            print(site, data)

        another_robo = await Roboragi.from_sqlite(
            mal_config, anilist_config, another_path
        )
        print(await another_robo.get_data(
            'Love Live Sunshine!', Medium.ANIME
        ))<commit_msg>remove anilist config arguments<commit_after>.. _quickstart:

Quickstart
==========
This page gives a brief introduction to the library.
It assumes you have the library installed,
if you don’t check the :ref:`install` portion.

The code block below showcases the basic usage using the built in support for
PostgreSQL and SQLite3.

.. code-block:: python3

    from pathlib import Path

    from roboragi import Medium, Roboragi, Site

    mal_config = {
        'user': 'MAL User name',
        'password': '<PASSWORD>'
    }

    async def postgres():
        postgres_config = {
            "host": "localhost",
            "port": "5432",
            "user": "postgres",
            "database": "postgres"
        }

        # You can choose how many pages from Anilist
        # and how many entries from MAL
        # to cache at the instance creation.
        robo = await Roboragi.from_postgres(
            mal_config, postgres_config,
            cache_pages=1, cache_mal_entries=30
        )

        # get_data eagerly evaluates all the data
        # and return them in a dict
        saekano = await robo.get_data(
            'Saenai Heroine no Sodatekata', Medium.ANIME
        )
        for site, data in saekano.items():
            print(site, data)

        # yield_data lazily evaluates the data
        # and you can iterate over them as such
        async for site, data in robo.yield_data('New Game!',
                                                Medium.MANGA):
            print(site, data)


    async def sqlite():
        # from_sqlite method accepts a string or a Pathlib Path object.
        sqlite_path = 'path/to/sqlite/database'
        another_path = Path('another/sqlite/path')

        robo = await Roboragi.from_sqlite(
            mal_config, sqlite_path
        )

        # We only want the results from those 2 sites.
        sites = (Site.LNDB, Site.MAL)
        async for site, data in robo.get_data(
            'overlord', Medium.LN, sites):
            print(site, data)

        another_robo = await Roboragi.from_sqlite(
            mal_config, another_path
        )
        print(await another_robo.get_data(
            'Love Live Sunshine!', Medium.ANIME
        ))
{'fraction_non_alphanumeric': 0.08327868852459017, 'fraction_numerical': 0.004371584699453552, 'mean_word_length': 1.9560723514211886, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6136755', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1278, 'n_words': 429}