Spaces:
Sleeping
Sleeping
davidmezzetti
commited on
Commit
•
fe65089
1
Parent(s):
55cb857
Delete textractor.py
Browse files- textractor.py +0 -25
textractor.py
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
"""
|
2 |
-
Textractor module
|
3 |
-
"""
|
4 |
-
|
5 |
-
import requests
|
6 |
-
|
7 |
-
from bs4 import BeautifulSoup
|
8 |
-
|
9 |
-
from txtai.pipeline.segmentation import Segmentation
|
10 |
-
|
11 |
-
class Textractor(Segmentation):
|
12 |
-
"""
|
13 |
-
Extracts text from files.
|
14 |
-
"""
|
15 |
-
|
16 |
-
def __init__(self, sentences=False, lines=False, paragraphs=False, minlength=None, join=False):
|
17 |
-
super().__init__(sentences, lines, paragraphs, minlength, join)
|
18 |
-
|
19 |
-
def text(self, text):
|
20 |
-
# text is a url
|
21 |
-
response = requests.get(text)
|
22 |
-
html = response.text
|
23 |
-
|
24 |
-
soup = BeautifulSoup(html, features="html.parser")
|
25 |
-
return soup.get_text()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|