Spaces:
Sleeping
Sleeping
Rainsilves
commited on
Commit
·
6ab9084
1
Parent(s):
bba3423
first stuff
Browse files- app.py +47 -0
- requirements.txt +5 -0
app.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pysbd
|
2 |
+
from txtai.embeddings import Embeddings
|
3 |
+
import networkx as nx
|
4 |
+
from tqdm import tqdm
|
5 |
+
from txtai.graph import GraphFactory
|
6 |
+
from datasets import load_dataset
|
7 |
+
import streamlit as st
|
8 |
+
import streamlit.components.v1 as components
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
st.set_page_config(page_title="DebateKG")
|
13 |
+
st.title("DebateKG - Automatic Policy Debate Case Creation")
|
14 |
+
st.caption("github: https://github.com/Hellisotherpeople/DebateKG")
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
dataset = load_dataset("Hellisotherpeople/DebateSum", split = "train")
|
21 |
+
seg = pysbd.Segmenter(language="en", clean=False)
|
22 |
+
|
23 |
+
|
24 |
+
embeddings = Embeddings({
|
25 |
+
"path": "entence-transformers/all-mpnet-base-v2",
|
26 |
+
"content": True,
|
27 |
+
"functions": [
|
28 |
+
{"name": "graph", "function": "graph.attribute"},
|
29 |
+
],
|
30 |
+
"expressions": [
|
31 |
+
{"name": "topic", "expression": "graph(indexid, 'topic')"},
|
32 |
+
{"name": "topicrank", "expression": "graph(indexid, 'topicrank')"}
|
33 |
+
],
|
34 |
+
"graph": {
|
35 |
+
"limit": 100,
|
36 |
+
"minscore": 0.10,
|
37 |
+
"topics": {
|
38 |
+
"terms": 4,
|
39 |
+
"resolution" : 100
|
40 |
+
}
|
41 |
+
}
|
42 |
+
})
|
43 |
+
|
44 |
+
embeddings.load("DebateSum_SemanticGraph_mpnet_extract.tar.gz")
|
45 |
+
graph = embeddings.graph
|
46 |
+
|
47 |
+
print(graph.backend.number_of_nodes(), graph.backend.number_of_edges())
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
git+https://github.com/neuml/txtai#egg=txtai[graph,pipeline,similarity]
|
2 |
+
datasets
|
3 |
+
ipyplot
|
4 |
+
tqdm
|
5 |
+
pysbd
|