#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Mise en forme des données du SUTOM.

À partir du dictionnaire "vortaro_eo.txt", on produit les dictionnaires des mots
de 6, 7, 8 et 9 lettres.

fichier : vortaroj.py
auteur  : Bob
"""

# Programme principal ==========================================================
with (open("vortaro-eo.txt", "r", encoding="utf8") as f_in,
      open("vortaro_6.txt", "a", encoding="utf8") as f_6,
      open("vortaro_7.txt", "a", encoding="utf8") as f_7,
      open("vortaro_8.txt", "a", encoding="utf8") as f_8,
      open("vortaro_9.txt", "a", encoding="utf8") as f_9):
    for vorto in f_in:
        lng = len(vorto[:-1])
        if 6 <= lng <= 9:
            match lng:
                case 6: f_6.write(vorto)
                case 7: f_7.write(vorto)
                case 8: f_8.write(vorto)
                case 9: f_9.write(vorto)

print("\nTerminé !")
