Spaces:
Runtime error
Runtime error
napatswift
commited on
Commit
·
2872dd7
1
Parent(s):
a845606
Update
Browse files
app.py
CHANGED
@@ -51,7 +51,9 @@ def greet(pdf_file: gr.File, pdf_url: str, replacer_string):
|
|
51 |
if pdf_file is None and pdf_url is None:
|
52 |
return "# Please updload file or link to ratchakitcha file", "Please add file"
|
53 |
|
54 |
-
if not replacer_string:
|
|
|
|
|
55 |
if pdf_file:
|
56 |
pdf_path = pdf_file.name
|
57 |
else:
|
@@ -68,6 +70,7 @@ def get_metainfo(md_string):
|
|
68 |
pattern = 'หน้า \d+\s+เล่ม (\d+) ตอนที่ (\d+) ([ก-ฮ]+) ราชกิจจานุเบกษา (\d+) ([^\s]+) (\d+)\s+'
|
69 |
info = re.findall(pattern, md_string)
|
70 |
pattern = '(หน้า \d+\s+เล่ม \d+ ตอนที่ \d+ [ก-ฮ]+ ราชกิจจานุเบกษา \d+ [^\s]+ \d+)\s+'
|
|
|
71 |
info = [i for i in info[0]]
|
72 |
info[4] = months.get(info[4], info[4])
|
73 |
md_string = re.sub(pattern, r'\n[//]: # (\1)\n\n', md_string)
|
|
|
51 |
if pdf_file is None and pdf_url is None:
|
52 |
return "# Please updload file or link to ratchakitcha file", "Please add file"
|
53 |
|
54 |
+
if not replacer_string:
|
55 |
+
replacer_string = ' ำ=ำ, า=ำ,้หนา=หน้า,่เลม=เล่ม,๐=0,๑=1,๒=2,๓=3,๔=4,๕=5,๖=6,๗=7,๘=8,๙=9'
|
56 |
+
|
57 |
if pdf_file:
|
58 |
pdf_path = pdf_file.name
|
59 |
else:
|
|
|
70 |
pattern = 'หน้า \d+\s+เล่ม (\d+) ตอนที่ (\d+) ([ก-ฮ]+) ราชกิจจานุเบกษา (\d+) ([^\s]+) (\d+)\s+'
|
71 |
info = re.findall(pattern, md_string)
|
72 |
pattern = '(หน้า \d+\s+เล่ม \d+ ตอนที่ \d+ [ก-ฮ]+ ราชกิจจานุเบกษา \d+ [^\s]+ \d+)\s+'
|
73 |
+
if not info: return md_string
|
74 |
info = [i for i in info[0]]
|
75 |
info[4] = months.get(info[4], info[4])
|
76 |
md_string = re.sub(pattern, r'\n[//]: # (\1)\n\n', md_string)
|