khaerens commited on
Commit
154538c
β€’
2 Parent(s): 6c15ad4 91c8e56

Merge branch 'main' of https://huggingface.co/spaces/ml6team/Knowledge-graphs

Browse files
Files changed (6) hide show
  1. .vscode/launch.json +0 -16
  2. README.md +1 -29
  3. app.py +10 -0
  4. rebel.py +3 -1
  5. requirements.txt +42 -0
  6. utils.py +3 -1
.vscode/launch.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "name": "Python: Current File",
9
- "type": "python",
10
- "request": "launch",
11
- "program": "${file}",
12
- "console": "integratedTerminal",
13
- "justMyCode": false
14
- }
15
- ]
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -4,35 +4,7 @@ emoji: 🌐
4
  colorFrom: red
5
  colorTo: blue
6
  sdk: streamlit
7
- sdk_version: 1.2.0
8
  app_file: app.py
9
  pinned: false
10
  ---
11
-
12
- # Configuration
13
-
14
- `title`: _string_
15
- Display title for the Space
16
-
17
- `emoji`: _string_
18
- Space emoji (emoji-only character allowed)
19
-
20
- `colorFrom`: _string_
21
- Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
22
-
23
- `colorTo`: _string_
24
- Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
25
-
26
- `sdk`: _string_
27
- Can be either `gradio`, `streamlit`, or `static`
28
-
29
- `sdk_version` : _string_
30
- Only applicable for `streamlit` SDK.
31
- See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.
32
-
33
- `app_file`: _string_
34
- Path to your main application file (which contains either `gradio` or `streamlit` Python code, or `static` html code).
35
- Path is relative to the root of the repository.
36
-
37
- `pinned`: _boolean_
38
- Whether the Space stays on top of your list.
 
4
  colorFrom: red
5
  colorTo: blue
6
  sdk: streamlit
7
+ sdk_version: 1.17.0
8
  app_file: app.py
9
  pinned: false
10
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -1,5 +1,11 @@
1
  import streamlit as st
2
  import streamlit.components.v1 as components
 
 
 
 
 
 
3
  import rebel
4
  import wikipedia
5
  from utils import clip_text
@@ -20,6 +26,10 @@ wiki_state_variables = {
20
  free_text_state_variables = {
21
  'has_run_free': False,
22
  "html_free": ""
 
 
 
 
23
  }
24
 
25
  BUTTON_COLUMS = 4
 
1
  import streamlit as st
2
  import streamlit.components.v1 as components
3
+ <<<<<<< HEAD
4
+ =======
5
+ import networkx as nx
6
+ import matplotlib.pyplot as plt
7
+ from pyvis.network import Network
8
+ >>>>>>> 91c8e568c30c6d6761629f102cbb617239e13d26
9
  import rebel
10
  import wikipedia
11
  from utils import clip_text
 
26
  free_text_state_variables = {
27
  'has_run_free': False,
28
  "html_free": ""
29
+ <<<<<<< HEAD
30
+ =======
31
+
32
+ >>>>>>> 91c8e568c30c6d6761629f102cbb617239e13d26
33
  }
34
 
35
  BUTTON_COLUMS = 4
rebel.py CHANGED
@@ -4,6 +4,7 @@ from pyvis.network import Network
4
  from functools import lru_cache
5
  import spacy
6
 
 
7
 
8
  DEFAULT_LABEL_COLORS = {
9
  "ORG": "#7aecec",
@@ -28,7 +29,8 @@ DEFAULT_LABEL_COLORS = {
28
 
29
 
30
  def generate_knowledge_graph(texts: List[str], filename: str):
31
- nlp = spacy.load("en_core_web_sm")
 
32
  doc = nlp("\n".join(texts).lower())
33
  NERs = [ent.text for ent in doc.ents]
34
  NER_types = [ent.label_ for ent in doc.ents]
 
4
  from functools import lru_cache
5
  import spacy
6
 
7
+ import streamlit as st
8
 
9
  DEFAULT_LABEL_COLORS = {
10
  "ORG": "#7aecec",
 
29
 
30
 
31
  def generate_knowledge_graph(texts: List[str], filename: str):
32
+ nlp = load_spacy()
33
+
34
  doc = nlp("\n".join(texts).lower())
35
  NERs = [ent.text for ent in doc.ents]
36
  NER_types = [ent.label_ for ent in doc.ents]
requirements.txt CHANGED
@@ -1,9 +1,51 @@
1
  streamlit
2
  matplotlib
3
  pyvis==0.1.9
 
4
  networkx
5
  transformers
6
  spacy
7
  wikipedia
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.2.0/en_core_web_sm-3.2.0.tar.gz#egg=en_core_web_sm
9
  torch
 
1
  streamlit
2
  matplotlib
3
  pyvis==0.1.9
4
+ <<<<<<< HEAD
5
  networkx
6
  transformers
7
  spacy
8
  wikipedia
9
+ =======
10
+ PyYAML==6.0
11
+ pyzmq==22.3.0
12
+ regex==2021.11.10
13
+ requests==2.27.1
14
+ sacremoses==0.0.47
15
+ Send2Trash==1.8.0
16
+ six==1.16.0
17
+ smart-open==5.2.1
18
+ smmap==5.0.0
19
+ soupsieve==2.3.1
20
+ spacy==3.2.1
21
+ spacy-legacy==3.0.8
22
+ spacy-loggers==1.0.1
23
+ srsly==2.4.2
24
+ streamlit==1.22.0
25
+ terminado==0.12.1
26
+ testpath==0.5.0
27
+ thinc==8.0.13
28
+ tokenizers==0.10.3
29
+ toml==0.10.2
30
+ toolz==0.11.2
31
+ torch==1.10.1
32
+ tornado==6.1
33
+ tqdm==4.62.3
34
+ traitlets==5.1.1
35
+ transformers==4.15.0
36
+ typer==0.4.0
37
+ typing-extensions==4.0.1
38
+ tzdata==2021.5
39
+ tzlocal==4.1
40
+ urllib3==1.26.8
41
+ validators==0.18.2
42
+ wasabi==0.9.0
43
+ watchdog==2.1.6
44
+ wcwidth==0.2.5
45
+ webencodings==0.5.1
46
+ widgetsnbextension==3.5.2
47
+ wikipedia==1.4.0
48
+ zipp==3.7.0
49
+ >>>>>>> 91c8e568c30c6d6761629f102cbb617239e13d26
50
  https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.2.0/en_core_web_sm-3.2.0.tar.gz#egg=en_core_web_sm
51
  torch
utils.py CHANGED
@@ -3,4 +3,6 @@ def clip_text(t, lenght = 4):
3
  t_sub = t.replace("...", "dotdotdot")
4
  t_clipped = ".".join(t_sub.split(".")[:lenght]) + "."
5
  t_reverted = t_clipped.replace("dotdotdot", "...")
6
- return t_reverted
 
 
 
3
  t_sub = t.replace("...", "dotdotdot")
4
  t_clipped = ".".join(t_sub.split(".")[:lenght]) + "."
5
  t_reverted = t_clipped.replace("dotdotdot", "...")
6
+ return t_reverted
7
+
8
+