Skip to main content

LangLearnCopilot is a library to help you learn a 'human' language.

Project description

License: MIT   Poetry

LangLearnCopilot

LangLearnCopilot is a collection of functions and tools, to generate content in a proper format, to help you learn a new language.

For now, I am focusing on French (my personal interesting) and Spanish (for friends).

While this is a standalone library, my advice is, for the best results, to use its outcomes hand-in-hand with the awesome flashcards application, Anki

The main two applications at the moment

Installation

pip install langlearncopilot

Usage

You can find examples in the ./examples folder

Note: you need to set your OpenAI key first. If the OPENAI_API_KEY is declared already as an environment variable, or exisiting in the current folder in a .env file, then the package will find it.

Other wise, you can set it manually by calling

from langlearncopilot.llm_calls import set_openai_key

set_openai_key("ENTER KEY VALUE HERE")

Given a text, extract all the unique words and its translation from that text

from langlearncopilot import generators

generators.generate_unique_words(
    article="Bonjour, je m'appelle Jean. Je suis un étudiant à l'université de Paris."
)

returns

{
    'bonjour': 'hello',
    'je': 'i',
    "m'appelle": 'is called',
    'suis': 'am',
    'un': 'a',
    'étudiant': 'student',
    'à': 'at',
    "l'université": 'university',
    'de': 'of'
}

Given a word, generate 3 phrases that are using these words

from langlearncopilot import generators

generators.generate_phrases("combien")

returns

[
    {'combien': {'phrase': 'Combien de personnes sont venues à la fête?', 'translation': ' How many people came to the party?'}},
    {'combien': {'phrase': 'Combien coûte ce sac à dos?', 'translation': ' How much does this backpack cost?'}},
    {'combien': {'phrase': "Il m'a demandé combien de temps cela prendrait.", 'translation': ' He asked me how long it would take.'}}
]

Extract unique words from URL, with their translation

from langlearncopilot.parsers import get_text_from_webpage
from langlearncopilot.generators import generate_unique_words


def main():
    # Get text from a webpage
    text = get_text_from_webpage(
        url="https://www.lemonde.fr/planete/article/2023/08/27/comment-les-parcs-nationaux-americains-tentent-de-faire-face-aux-effets-du-rechauffement-climatique_6186696_3244.html"
    )
    # Generate unique words from the text
    words = generate_unique_words(article=text, language="french")
    print(words)


if __name__ == "__main__":
    main()

returns

{
    'comment': 'how',
    'les': 'the',
    'parcs': 'parks',
    'nationaux': 'national',
    'américains': 'american',
    'tentent': 'try',
    'de': 'of',
    ...
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langlearncopilot-0.3.1.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langlearncopilot-0.3.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file langlearncopilot-0.3.1.tar.gz.

File metadata

  • Download URL: langlearncopilot-0.3.1.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.9.18 Linux/5.15.0-1041-azure

File hashes

Hashes for langlearncopilot-0.3.1.tar.gz
Algorithm Hash digest
SHA256 0034be875dddf7cb8dfd0723d11daf9ee92f318aa2e6616b2cd968eb25565e99
MD5 04aac856d1fc6f5df8e0b9cb6c9f47aa
BLAKE2b-256 f9064b6d7619335df27c378ae2f94b2ba53166cfb73afdb8a33fd3c0ed6783f2

See more details on using hashes here.

File details

Details for the file langlearncopilot-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: langlearncopilot-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.9.18 Linux/5.15.0-1041-azure

File hashes

Hashes for langlearncopilot-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 98894bb3368b2d8c59b2789dd536b2cb86e317a4d9784031901453c3340cf495
MD5 b244175e1fbff1b50771b22be78b7058
BLAKE2b-256 291e79c4b9c139f9d5430c4b687a6b6a5887fa1b107e65c2caff10203bd473b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page