hitit-cuneiform-ocr / code /inspect_mark.py
savastakan's picture
Initial upload: code + 5 record checkpoints + fuse
f211247 verified
Raw
History Blame Contribute Delete
2.42 kB
"""mark.txt dosyalarının formatını keşfetmek için yardımcı script.
Kullanım: python3 inspect_mark.py
"""
import os
import json
MARK_PATH = "datasets/sources/hitit_local/32/mark.txt"
with open(MARK_PATH, "rb") as f:
raw = f.read(5000)
print("=== İlk 500 byte (raw) ===")
print(raw[:500])
print()
# Encoding dene
for enc in ("utf-8", "utf-16", "latin-1"):
try:
text = raw.decode(enc)
print(f"=== {enc} ile decode edildi, ilk 1000 karakter ===")
print(text[:1000])
print()
# JSON mu diye kontrol et
try:
full = open(MARK_PATH, "r", encoding=enc).read()
data = json.loads(full)
print(f"=== JSON olarak parse edildi ({enc}) ===")
if isinstance(data, dict):
print("Tip: dict")
print("Anahtarlar:", list(data.keys())[:20])
for key in list(data.keys())[:5]:
val = data[key]
if isinstance(val, list):
print(f" {key}: list, uzunluk={len(val)}")
if len(val) > 0:
print(f" İlk eleman: {str(val[0])[:300]}")
elif isinstance(val, dict):
print(f" {key}: dict, anahtarlar={list(val.keys())[:10]}")
else:
print(f" {key}: {type(val).__name__} = {str(val)[:200]}")
elif isinstance(data, list):
print(f"Tip: list, uzunluk={len(data)}")
if len(data) > 0:
print(f"İlk eleman tipi: {type(data[0]).__name__}")
print(f"İlk eleman: {str(data[0])[:500]}")
except json.JSONDecodeError as e:
print(f"JSON parse hatası ({enc}): {e}")
except Exception as e:
print(f"Hata ({enc}): {e}")
break
except UnicodeDecodeError:
print(f"{enc} ile decode edilemedi")
# Dosya boyutu
size = os.path.getsize(MARK_PATH)
print(f"\nDosya boyutu: {size} byte ({size/1024:.1f} KB)")
# Tüm mark.txt dosyalarını listele ve boyutlarını göster
print("\n=== Tüm mark.txt dosyaları ===")
for root, dirs, files in os.walk("datasets" / "sources" / "hitit_local"):
for f in files:
if f == "mark.txt":
path = os.path.join(root, f)
size = os.path.getsize(path)
print(f" {path}: {size/1024:.1f} KB")