Spaces:
Runtime error
Runtime error
Commit
·
6d14e62
1
Parent(s):
9c923b0
update requirements.txt
Browse files- app.py +23 -8
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -37,12 +37,6 @@ def main() -> None:
|
|
| 37 |
for senetence in summary_sentences:
|
| 38 |
st.markdown(f"<li>{senetence}</li>", unsafe_allow_html=True)
|
| 39 |
|
| 40 |
-
def is_valid_url(url: str) -> bool:
|
| 41 |
-
result = validators.url(url)
|
| 42 |
-
if isinstance(result, ValidationFailure):
|
| 43 |
-
return False
|
| 44 |
-
return True
|
| 45 |
-
|
| 46 |
def get_list_files() -> list:
|
| 47 |
names = []
|
| 48 |
for file in os.listdir("./samples/"):
|
|
@@ -101,11 +95,32 @@ def main() -> None:
|
|
| 101 |
# with st.spinner("Summarizing in progress..."):
|
| 102 |
# return tuple(summarizer.abstractive_summary(list(summary_sentence)))
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
pipe = create_pipeline()
|
| 105 |
|
| 106 |
if summarize_button:
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
|
| 111 |
if __name__ == "__main__":
|
|
|
|
| 37 |
for senetence in summary_sentences:
|
| 38 |
st.markdown(f"<li>{senetence}</li>", unsafe_allow_html=True)
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
def get_list_files() -> list:
|
| 41 |
names = []
|
| 42 |
for file in os.listdir("./samples/"):
|
|
|
|
| 95 |
# with st.spinner("Summarizing in progress..."):
|
| 96 |
# return tuple(summarizer.abstractive_summary(list(summary_sentence)))
|
| 97 |
|
| 98 |
+
def split_text(text: str) -> list:
|
| 99 |
+
tokens = nltk.tokenize(text)
|
| 100 |
+
sentences = []
|
| 101 |
+
token_count = 0
|
| 102 |
+
sentence = ""
|
| 103 |
+
for token in tokens not in ["."]:
|
| 104 |
+
if token_count < 1024:
|
| 105 |
+
sentence += "".join(token + " ")
|
| 106 |
+
token_count += 1
|
| 107 |
+
else:
|
| 108 |
+
sentences.append(sentence)
|
| 109 |
+
token_count = 0
|
| 110 |
+
sentence = ""
|
| 111 |
+
|
| 112 |
+
return sentences
|
| 113 |
+
|
| 114 |
pipe = create_pipeline()
|
| 115 |
|
| 116 |
if summarize_button:
|
| 117 |
+
if target_text_input is not "":
|
| 118 |
+
with st.spinner("Summarizing in progress..."):
|
| 119 |
+
sentences = split_text(target_text_input)
|
| 120 |
+
for sentence in sentences:
|
| 121 |
+
output = pipe(sentence)
|
| 122 |
+
|
| 123 |
+
st.markdown(output['summary_text'])
|
| 124 |
|
| 125 |
|
| 126 |
if __name__ == "__main__":
|
requirements.txt
CHANGED
|
@@ -68,6 +68,7 @@ tokenizers==0.12.1
|
|
| 68 |
toml==0.10.2
|
| 69 |
toolz==0.12.0
|
| 70 |
torch==1.12.1
|
|
|
|
| 71 |
tornado==6.2
|
| 72 |
tqdm==4.64.0
|
| 73 |
traitlets==5.3.0
|
|
|
|
| 68 |
toml==0.10.2
|
| 69 |
toolz==0.12.0
|
| 70 |
torch==1.12.1
|
| 71 |
+
torchvision==0.13.1
|
| 72 |
tornado==6.2
|
| 73 |
tqdm==4.64.0
|
| 74 |
traitlets==5.3.0
|