Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,20 @@
|
|
|
|
|
|
|
|
1 |
import numpy as np
|
2 |
import onnxruntime
|
3 |
import onnx
|
4 |
import gradio as gr
|
5 |
import requests
|
6 |
import json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
from extractnet import Extractor
|
8 |
import math
|
9 |
from transformers import AutoTokenizer
|
@@ -275,8 +286,15 @@ def inference(input_batch,isurl,use_archive,limit_companies=10):
|
|
275 |
if archive['archived']:
|
276 |
url = archive['url']
|
277 |
#Extract the data from url
|
278 |
-
|
279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
else:
|
281 |
print("[i] Data is news contents")
|
282 |
if isinstance(input_batch_r[0], list):
|
|
|
1 |
+
#Choose the extractor. Both extractnet & dragnet have dependency conflicts with bertopic
|
2 |
+
EXTRACTOR_NET = 'trafilatura'
|
3 |
+
|
4 |
import numpy as np
|
5 |
import onnxruntime
|
6 |
import onnx
|
7 |
import gradio as gr
|
8 |
import requests
|
9 |
import json
|
10 |
+
|
11 |
+
if(EXTRACTOR_NET == 'extractnet'):
|
12 |
+
from extractnet import Extractor
|
13 |
+
elif(EXTRACTOR_NET == 'dragnet'):
|
14 |
+
from dragnet import extract_content
|
15 |
+
elif(EXTRACTOR_NET == 'trafilatura'):
|
16 |
+
import trafilatura
|
17 |
+
|
18 |
from extractnet import Extractor
|
19 |
import math
|
20 |
from transformers import AutoTokenizer
|
|
|
286 |
if archive['archived']:
|
287 |
url = archive['url']
|
288 |
#Extract the data from url
|
289 |
+
if(EXTRACTOR_NET == 'extractnet'):
|
290 |
+
extracted = Extractor().extract(requests.get(url).text)
|
291 |
+
input_batch_content.append(extracted['content'])
|
292 |
+
elif(EXTRACTOR_NET == 'dragnet'):
|
293 |
+
extracted = extract_content(requests.get(url).content)
|
294 |
+
input_batch_content.append(extracted)
|
295 |
+
elif(EXTRACTOR_NET == 'trafilatura'):
|
296 |
+
extracted = trafilatura.extract(trafilatura.fetch_url(url), include_comments=False)
|
297 |
+
input_batch_content.append(extracted)
|
298 |
else:
|
299 |
print("[i] Data is news contents")
|
300 |
if isinstance(input_batch_r[0], list):
|