help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
language-translation
/
scripts
RSK World
language-translation
Language Translation Dataset - Machine Translation + Multilingual NLP + Parallel Corpus + Transformers
scripts
  • __pycache__
  • analyze_dataset.py4.6 KB
  • build_local_dictionary.py6.7 KB
  • convert_format.py3.6 KB
  • create_zip.py4.1 KB
  • download_translation_data.py17.6 KB
  • process_data.py3.9 KB
requirements.txtanalyze_dataset.py
requirements.txt
Raw Download
Find: Go to:
# Language Translation Dataset - Requirements
# Author: RSK World
# Website: https://rskworld.in
# Email: help@rskworld.in
# Phone: +91 93305 39277
# Copyright © 2016 RSK World. All rights reserved.

pandas>=2.0.0
numpy>=1.24.0
transformers>=4.30.0
torch>=2.0.0
sentencepiece>=0.1.99

14 lines•299 B
text
scripts/analyze_dataset.py
Raw Download
Find: Go to:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Language Translation Dataset - Dataset Analysis Script
Author: RSK World
Website: https://rskworld.in
Email: help@rskworld.in
Phone: +91 93305 39277
Copyright © 2016 RSK World. All rights reserved.

This script provides detailed analysis of the language translation dataset.
"""

import pandas as pd
import json
from pathlib import Path
from collections import Counter

def analyze_tsv_dataset(filepath):
    """
    Analyze TSV dataset and provide statistics.
    
    Args:
        filepath: Path to TSV file
    """
    print(f"\n{'='*60}")
    print(f"Analyzing: {filepath.name}")
    print(f"{'='*60}")
    
    df = pd.read_csv(filepath, sep='\t', encoding='utf-8')
    
    print(f"\nDataset Shape: {df.shape[0]} rows × {df.shape[1]} columns")
    print(f"\nColumns: {', '.join(df.columns)}")
    
    # Basic statistics
    print(f"\n--- Basic Statistics ---")
    print(df.describe())
    
    # Language-specific analysis
    language_columns = ['english', 'spanish', 'french', 'german']
    available_languages = [col for col in language_columns if col in df.columns]
    
    if available_languages:
        print(f"\n--- Language Analysis ---")
        for lang in available_languages:
            if lang in df.columns:
                sentences = df[lang].dropna()
                avg_length = sentences.str.len().mean()
                max_length = sentences.str.len().max()
                min_length = sentences.str.len().min()
                
                print(f"\n{lang.capitalize()}:")
                print(f"  Total sentences: {len(sentences)}")
                print(f"  Average length: {avg_length:.2f} characters")
                print(f"  Max length: {max_length} characters")
                print(f"  Min length: {min_length} characters")
    
    # Sample data
    print(f"\n--- Sample Data (First 3 rows) ---")
    print(df.head(3).to_string())
    
    return df

def analyze_json_dataset(filepath):
    """
    Analyze JSON dataset and provide statistics.
    
    Args:
        filepath: Path to JSON file
    """
    print(f"\n{'='*60}")
    print(f"Analyzing: {filepath.name}")
    print(f"{'='*60}")
    
    with open(filepath, 'r', encoding='utf-8') as f:
        data = json.load(f)
    
    print(f"\nTotal Records: {len(data)}")
    
    if data:
        print(f"\nKeys: {', '.join(data[0].keys())}")
        
        # Language-specific analysis
        language_keys = ['english', 'spanish', 'french', 'german']
        available_languages = [key for key in language_keys if key in data[0]]
        
        if available_languages:
            print(f"\n--- Language Analysis ---")
            for lang in available_languages:
                lengths = [len(record[lang]) for record in data if lang in record and record[lang]]
                if lengths:
                    avg_length = sum(lengths) / len(lengths)
                    max_length = max(lengths)
                    min_length = min(lengths)
                    
                    print(f"\n{lang.capitalize()}:")
                    print(f"  Total sentences: {len(lengths)}")
                    print(f"  Average length: {avg_length:.2f} characters")
                    print(f"  Max length: {max_length} characters")
                    print(f"  Min length: {min_length} characters")
        
        # Sample data
        print(f"\n--- Sample Data (First 3 records) ---")
        for i, record in enumerate(data[:3], 1):
            print(f"\nRecord {i}:")
            print(json.dumps(record, indent=2, ensure_ascii=False))
    
    return data

def main():
    """Main analysis function."""
    print("=" * 60)
    print("Language Translation Dataset - Analysis Tool")
    print("Author: RSK World (https://rskworld.in)")
    print("=" * 60)
    
    BASE_DIR = Path(__file__).parent.parent
    DATA_DIR = BASE_DIR / 'data'
    
    # Analyze training data
    train_tsv = DATA_DIR / 'train.tsv'
    train_json = DATA_DIR / 'train.json'
    
    if train_tsv.exists():
        analyze_tsv_dataset(train_tsv)
    elif train_json.exists():
        analyze_json_dataset(train_json)
    
    # Analyze validation data
    val_tsv = DATA_DIR / 'validation.tsv'
    val_json = DATA_DIR / 'validation.json'
    
    if val_tsv.exists():
        analyze_tsv_dataset(val_tsv)
    elif val_json.exists():
        analyze_json_dataset(val_json)
    
    print(f"\n{'='*60}")
    print("Analysis complete!")
    print(f"{'='*60}")

if __name__ == '__main__':
    main()

145 lines•4.6 KB
python

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer