or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/googletrans@4.0.x
tile.json

tessl/pypi-googletrans

tessl install tessl/pypi-googletrans@4.0.0

An unofficial Google Translate API for Python providing free text translation and language detection capabilities

Agent Success

Agent success rate when using this tile

100%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.01x

Baseline

Agent success rate without this tile

99%

task.mdevals/scenario-9/

Multi-Language Content Analyzer

Build a content analyzer that detects the languages used in text samples and reports language distribution statistics.

Requirements

Your program should:

  1. Accept a list of text samples (strings) as input
  2. Detect the language for each text sample
  3. Calculate and report statistics including:
    • The detected language code for each sample
    • The confidence score for each detection
    • A summary showing the count of samples for each language detected
  4. Handle both single text analysis and batch analysis of multiple texts
  5. Use async/await patterns for all operations
  6. Ensure proper resource cleanup

Test Cases

Single Text Detection

  • When analyzing the text "Hello, how are you today?", the system detects English (language code "en") with a confidence score @test
  • When analyzing the text "Bonjour, comment allez-vous?", the system detects French (language code "fr") with a confidence score @test
  • When analyzing the text "こんにちは、元気ですか?", the system detects Japanese (language code "ja") with a confidence score @test

Batch Detection

  • When analyzing multiple texts ["Hello world", "Hola mundo", "Ciao mondo"], the system returns detection results for all three texts in order @test

Statistics Generation

  • When provided with texts in multiple languages, the system generates a summary dictionary mapping each language code to the count of samples in that language @test

Implementation

@generates

API

from typing import List, Dict

async def detect_language(text: str) -> Dict[str, any]:
    """
    Detects the language of a single text sample.

    Args:
        text: The text to analyze

    Returns:
        A dictionary containing:
        - 'language': The detected language code
        - 'confidence': The confidence score (float between 0 and 1)
        - 'text': The original text
    """
    pass

async def analyze_batch(texts: List[str]) -> List[Dict[str, any]]:
    """
    Analyzes multiple text samples and detects their languages.

    Args:
        texts: List of text samples to analyze

    Returns:
        List of dictionaries, each containing language detection results
    """
    pass

async def generate_language_stats(texts: List[str]) -> Dict[str, int]:
    """
    Generates statistics about language distribution in a collection of texts.

    Args:
        texts: List of text samples to analyze

    Returns:
        Dictionary mapping language codes to the count of samples in that language
    """
    pass

Dependencies { .dependencies }

googletrans { .dependency }

Provides language detection capabilities for text analysis.