Spaces:
Sleeping
Sleeping
File size: 717 Bytes
463f868 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import re
with open("card_text.txt", "r", encoding="utf-8") as f:
text = f.read()
print(f"Original Text Length: {len(text)}")
text = text.replace("<br>", "\n")
blocks = re.split(r"\\n|\n", text)
print(f"Blocks: {len(blocks)}")
block = blocks[0].strip()
print(f"Block 0 Length: {len(block)}")
sentences = [s.strip() for s in re.split(r"。\s*", block) if s.strip()]
print(f"Sentences: {len(sentences)}")
line = sentences[0]
print(f"Sentence 0: ...{line[-30:]}...") # End of sentence
full_content = re.sub(r"(.*?)|\(.*?\)", "", line)
print(f"Full Content: ...{full_content[-30:]}...")
print(f"Pay in Line: {'払' in line}")
print(f"Pay in Full Content: {'払' in full_content}")
|