Spaces:
Build error
Build error
Create tokenization.py
Browse files- tokenization.py +20 -0
tokenization.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
from urllib.request import urlopen
|
| 5 |
+
from bs4 import BeautifulSoup
|
| 6 |
+
|
| 7 |
+
url = "https://raw.githubusercontent.com/cltk/hindi_text_ltrc/master/tulasidaas/Raamacharita_maanasa/1/main.txt"
|
| 8 |
+
html = urlopen(url).read()
|
| 9 |
+
soup = BeautifulSoup(html, features="html.parser")
|
| 10 |
+
|
| 11 |
+
# kill all script and style elements
|
| 12 |
+
for script in soup(["script", "style"]):
|
| 13 |
+
script.extract() # rip it out
|
| 14 |
+
|
| 15 |
+
# get text
|
| 16 |
+
text = soup.get_text()
|
| 17 |
+
ramayana_text = text
|
| 18 |
+
print(type(text))
|
| 19 |
+
|
| 20 |
+
|