Spaces:
Runtime error
Runtime error
Lodor
commited on
Commit
•
bc4670d
1
Parent(s):
1be0f77
Initial commit
Browse files- .gitignore +124 -0
- .streamlit/config.toml +6 -0
- Dockerfile +9 -0
- app.py +33 -0
- assets/demo.png +0 -0
- assets/paraphrase-v1.yml +45 -0
- docker-compose.yml +13 -0
- output/results.json +0 -0
- requirements.txt +5 -0
- src/__init__.py +0 -0
- src/st_style.py +42 -0
- src/utils.py +16 -0
.gitignore
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
wheels/
|
23 |
+
pip-wheel-metadata/
|
24 |
+
share/python-wheels/
|
25 |
+
*.egg-info/
|
26 |
+
.installed.cfg
|
27 |
+
*.egg
|
28 |
+
MANIFEST
|
29 |
+
|
30 |
+
# PyInstaller
|
31 |
+
# Usually these files are written by a python script from a template
|
32 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
33 |
+
*.manifest
|
34 |
+
*.spec
|
35 |
+
|
36 |
+
# Installer logs
|
37 |
+
pip-log.txt
|
38 |
+
pip-delete-this-directory.txt
|
39 |
+
|
40 |
+
# Unit test / coverage reports
|
41 |
+
htmlcov/
|
42 |
+
.tox/
|
43 |
+
.nox/
|
44 |
+
.coverage
|
45 |
+
.coverage.*
|
46 |
+
.cache
|
47 |
+
nosetests.xml
|
48 |
+
coverage.xml
|
49 |
+
*.cover
|
50 |
+
.hypothesis/
|
51 |
+
.pytest_cache/
|
52 |
+
|
53 |
+
# Translations
|
54 |
+
*.mo
|
55 |
+
*.pot
|
56 |
+
|
57 |
+
# Django stuff:
|
58 |
+
*.log
|
59 |
+
local_settings.py
|
60 |
+
db.sqlite3
|
61 |
+
db.sqlite3-journal
|
62 |
+
|
63 |
+
# Flask stuff:
|
64 |
+
instance/
|
65 |
+
.webassets-cache
|
66 |
+
|
67 |
+
# Scrapy stuff:
|
68 |
+
.scrapy
|
69 |
+
|
70 |
+
# Sphinx documentation
|
71 |
+
docs/_build/
|
72 |
+
|
73 |
+
# PyBuilder
|
74 |
+
target/
|
75 |
+
|
76 |
+
# Jupyter Notebook
|
77 |
+
.ipynb_checkpoints
|
78 |
+
|
79 |
+
# IPython
|
80 |
+
profile_default/
|
81 |
+
ipython_config.py
|
82 |
+
|
83 |
+
# pyenv
|
84 |
+
.python-version
|
85 |
+
|
86 |
+
# pipenv
|
87 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
88 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
89 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
90 |
+
# install all needed dependencies.
|
91 |
+
#Pipfile.lock
|
92 |
+
|
93 |
+
# celery beat schedule file
|
94 |
+
celerybeat-schedule
|
95 |
+
|
96 |
+
# SageMath parsed files
|
97 |
+
*.sage.py
|
98 |
+
|
99 |
+
# Environments
|
100 |
+
.env
|
101 |
+
.venv
|
102 |
+
env/
|
103 |
+
venv/
|
104 |
+
ENV/
|
105 |
+
env.bak/
|
106 |
+
venv.bak/
|
107 |
+
|
108 |
+
# Spyder project settings
|
109 |
+
.spyderproject
|
110 |
+
.spyproject
|
111 |
+
|
112 |
+
# Rope project settings
|
113 |
+
.ropeproject
|
114 |
+
|
115 |
+
# mkdocs documentation
|
116 |
+
/site
|
117 |
+
|
118 |
+
# mypy
|
119 |
+
.mypy_cache/
|
120 |
+
.dmypy.json
|
121 |
+
dmypy.json
|
122 |
+
|
123 |
+
# Pyre type checker
|
124 |
+
.pyre/
|
.streamlit/config.toml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[server]
|
2 |
+
maxUploadSize = 10
|
3 |
+
|
4 |
+
[theme]
|
5 |
+
base="light"
|
6 |
+
primaryColor="#0074ff"
|
Dockerfile
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9.12-buster
|
2 |
+
|
3 |
+
WORKDIR /app
|
4 |
+
|
5 |
+
COPY . .
|
6 |
+
|
7 |
+
RUN pip install -r requirements.txt
|
8 |
+
|
9 |
+
CMD [ "streamlit", "run", "app.py" ]
|
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import time
|
3 |
+
from src.utils import paraphrase_english, paraphrase_indonesian
|
4 |
+
from src.st_style import apply_prod_style
|
5 |
+
|
6 |
+
|
7 |
+
# apply_prod_style(st) # NOTE: Uncomment this for production!
|
8 |
+
|
9 |
+
st.title("AI Text Paraphraser")
|
10 |
+
st.image(open("assets/demo.png", "rb").read())
|
11 |
+
st.write(
|
12 |
+
"""
|
13 |
+
Stop plagiarism! Do not carelessly copy and paste text materials from the internet.
|
14 |
+
**This AI tool will make your text unique and free from plagiarism.**
|
15 |
+
"""
|
16 |
+
)
|
17 |
+
|
18 |
+
language = st.selectbox("Language", ["English", "Bahasa Indonesia"])
|
19 |
+
input_text = st.text_area("Input your text (Max 1000 characters)", height=250, max_chars=1000)
|
20 |
+
|
21 |
+
if st.button("Submit") and len(input_text) > 0:
|
22 |
+
|
23 |
+
with st.spinner("AI is doing the magic!") as p:
|
24 |
+
input_text = input_text.replace("\n\n", "\n").replace("\n", " ").strip()
|
25 |
+
|
26 |
+
if language == "English":
|
27 |
+
paraphrased = paraphrase_english(input_text)
|
28 |
+
else:
|
29 |
+
paraphrased = paraphrase_indonesian(input_text)
|
30 |
+
|
31 |
+
st.write("**Your text is ready!**")
|
32 |
+
st.write(paraphrased)
|
33 |
+
st.info("**TIP:** You can submit the same text multiple times to get different results.")
|
assets/demo.png
ADDED
assets/paraphrase-v1.yml
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
engine:
|
2 |
+
name: "PriorityEngine"
|
3 |
+
engines:
|
4 |
+
- name: "TextsynthEngine"
|
5 |
+
model: "gptj_6B"
|
6 |
+
api_key: "9a0fff5b41a9cc3e8c81104ae45ac403"
|
7 |
+
- name: "EleutherEngine"
|
8 |
+
model: "GPT-J-6B"
|
9 |
+
|
10 |
+
stop_string: "\n"
|
11 |
+
temperature: 0.95
|
12 |
+
top_p: 0.9
|
13 |
+
top_k: 50
|
14 |
+
max_generated_tokens: 200
|
15 |
+
seed: 0
|
16 |
+
force_safety: false
|
17 |
+
on_stream: null
|
18 |
+
prompt: |
|
19 |
+
Original Text: Getting maximum value from IT is as much about how you manage it as it is about investing in it. From a business perspective it is about harmonizing IT; organizing IT; managing IT (Curley 2004), and identifying the value delivered to the organization (Prahalad and Hamel 1990, Sward and Haas 2003). Link this to UXD to deliver what the market wants and you have the basis for a competitive advantage (Sward 2006a). Understand how to do it continually and you have a sustainable competitive advantage to assist the corporate strategy (Porter 1987, Hamel and Prahalad 1994). Strategy one focuses on understanding the value delivered by solutions, strategy two focuses on getting UCD skills embedded in the organization, and strategy three focuses on effectively managing the UXD capability
|
20 |
+
|
21 |
+
Paraphrased Text: To get the optimized value from IT to provide competitive advantage in the current business environment, management is the most important aspect. In a competitive world, we need businesses to help their best and brightest realize the greatest contribution. UXD (User Experience Design) is instrumental in helping us to deliver on this and get the maximum value from it. Doing this requires helping to manage the impact of this change on its activities in a practical way by helping them to communicate cross-functionally.
|
22 |
+
|
23 |
+
---
|
24 |
+
|
25 |
+
Original Text: To execute this strategy, organizations need to employ a consistent, repeatable, and objective process that measures forecasted and delivered value as defined by the customers and users. There are many approaches for quantifying IT returns. In e-commerce management, using a systematic value-driven analysis approach is aligned with maximizing value creation and minimizing loss to increase business performance (Hahn et al. 2002).
|
26 |
+
|
27 |
+
Paraphrased Text: This strategy requires a systematic way of ensuring that IT (Information Technology) is delivering value to the organization, and doing it in a way that is objective, repeatable, and consistent. This can be achieved by measuring the value being delivered, the value that customers and users consider important to them, and the expected value. There are many approaches to quantifying IT value. Measuring value using a value chain approach is aligned with maximizing value creation and minimizing loss to improve the businesses performance.
|
28 |
+
|
29 |
+
---
|
30 |
+
|
31 |
+
Original Text: Artificial intelligence (AI) is a wide-ranging branch of computer science concerned with building smart machines capable of performing tasks that typically require human intelligence.
|
32 |
+
|
33 |
+
Paraphrased Text: AI (Artificial Intelligence) is a broad discipline of computer science that involves building intelligent machines capable of doing tasks that traditionally need human intelligence.
|
34 |
+
|
35 |
+
---
|
36 |
+
|
37 |
+
Original Text: Health care or healthcare is the maintenance or improvement of health via the prevention, diagnosis, treatment, amelioration, or cure of disease, illness, injury, and other physical and mental impairments in people. Health care is delivered by health professionals and allied health fields. Medicine, dentistry, pharmacy, midwifery, nursing, optometry, audiology, psychology, occupational therapy, physical therapy, athletic training, and other health professions are all part of health care. It includes work done in providing primary care, secondary care, and tertiary care, as well as in public health.
|
38 |
+
|
39 |
+
Paraphrased Text: The prevention, diagnosis, treatment, amelioration, or cure of disease, illness, injury, and other physical and mental disabilities in individuals is referred to as health care or healthcare. Health care is provided by specialists in the medical and allied health sectors. Health professionals include doctors, dentists, pharmacists, midwives, nurses, optometrists, audiologists, psychologists, occupational therapists, physical therapists, athletic trainers, and others. It encompasses work in primary care, secondary care, and tertiary care, as well as public health.
|
40 |
+
|
41 |
+
---
|
42 |
+
|
43 |
+
Original Text: {{text}}
|
44 |
+
|
45 |
+
Paraphrased Text:
|
docker-compose.yml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
version: '3'
|
3 |
+
services:
|
4 |
+
st-paraphrase:
|
5 |
+
build: .
|
6 |
+
container_name: st-paraphrase
|
7 |
+
restart: unless-stopped
|
8 |
+
ports:
|
9 |
+
- 51002:8501
|
10 |
+
volumes:
|
11 |
+
- .:/app
|
12 |
+
environment:
|
13 |
+
- TZ=Asia/Jakarta
|
output/results.json
ADDED
File without changes
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
git+https://github.com/lodorg/easytextgen
|
2 |
+
streamlit
|
3 |
+
translate
|
4 |
+
requests
|
5 |
+
tinydb
|
src/__init__.py
ADDED
File without changes
|
src/st_style.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
button_style = """
|
2 |
+
<style>
|
3 |
+
div.stButton > button:first-child {
|
4 |
+
background-color: rgb(255, 75, 75);
|
5 |
+
color: rgb(255, 255, 255);
|
6 |
+
}
|
7 |
+
div.stButton > button:hover {
|
8 |
+
background-color: rgb(255, 75, 75);
|
9 |
+
color: rgb(255, 255, 255);
|
10 |
+
}
|
11 |
+
div.stButton > button:active {
|
12 |
+
background-color: rgb(255, 75, 75);
|
13 |
+
color: rgb(255, 255, 255);
|
14 |
+
}
|
15 |
+
div.stButton > button:focus {
|
16 |
+
background-color: rgb(255, 75, 75);
|
17 |
+
color: rgb(255, 255, 255);
|
18 |
+
}
|
19 |
+
.css-1cpxqw2:focus:not(:active) {
|
20 |
+
background-color: rgb(255, 75, 75);
|
21 |
+
border-color: rgb(255, 75, 75);
|
22 |
+
color: rgb(255, 255, 255);
|
23 |
+
}
|
24 |
+
"""
|
25 |
+
|
26 |
+
style = """
|
27 |
+
<style>
|
28 |
+
#MainMenu {
|
29 |
+
visibility: hidden;
|
30 |
+
}
|
31 |
+
footer {
|
32 |
+
visibility: hidden;
|
33 |
+
}
|
34 |
+
header {
|
35 |
+
visibility: hidden;
|
36 |
+
}
|
37 |
+
</style>
|
38 |
+
"""
|
39 |
+
|
40 |
+
|
41 |
+
def apply_prod_style(st):
|
42 |
+
return st.markdown(style, unsafe_allow_html=True)
|
src/utils.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from easytextgen import EasyPrompt
|
2 |
+
from translate import Translator
|
3 |
+
|
4 |
+
trans_to_id = Translator(to_lang="id")
|
5 |
+
trans_to_en = Translator(to_lang="en")
|
6 |
+
prompt = EasyPrompt.from_file("assets/paraphrase-v1.yml")
|
7 |
+
|
8 |
+
|
9 |
+
def paraphrase_english(english_text: str) -> str:
|
10 |
+
return prompt.get_output(english_text).output_text.strip()
|
11 |
+
|
12 |
+
|
13 |
+
def paraphrase_indonesian(indonesian_text: str) -> str:
|
14 |
+
eng_text = trans_to_en.translate(indonesian_text)
|
15 |
+
eng_paraphrased = paraphrase_english(eng_text)
|
16 |
+
return trans_to_id.translate(eng_paraphrased)
|