Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datasets import load_dataset
|
2 |
+
from datasets import Dataset
|
3 |
+
from langchain.docstore.document import Document as LangchainDocument
|
4 |
+
from sentence_transformers import SentenceTransformer
|
5 |
+
|
6 |
+
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
7 |
+
from langchain_community.document_loaders import PyPDFLoader, DirectoryLoader
|
8 |
+
from sentence_transformers import SentenceTransformer
|
9 |
+
from huggingface_hub import Repository, upload_file
|
10 |
+
|
11 |
+
url = "https://oxyjon.com/blog/"
|
12 |
+
loader = WebBaseLoader(url)
|
13 |
+
document = loader.load()
|
14 |
+
|
15 |
+
# split the document into chunks
|
16 |
+
text_splitter = RecursiveCharacterTextSplitter(chunk_size=256, chunk_overlap=50)
|
17 |
+
texts = text_splitter.split_documents(document)
|
18 |
+
print(texts[1])
|
19 |
+
print(texts[3)
|
20 |
+
print(texts[17)
|
21 |
+
|