Valeriy Sinyukov
commited on
Commit
·
fe3279c
1
Parent(s):
90a7e15
Add authors to input
Browse files
app.py
CHANGED
@@ -7,9 +7,14 @@ from languages import *
|
|
7 |
page_title = {en: "Papers classification", ru: "Классификация статей"}
|
8 |
model_label = {en: "Select model", ru: "Выберете модель"}
|
9 |
title_label = {en: "Title", ru: "Название статьи"}
|
|
|
10 |
abstract_label = {en: "Abstract", ru: "Аннотация"}
|
11 |
|
12 |
|
|
|
|
|
|
|
|
|
13 |
@st.cache_data
|
14 |
def load_class_model(name):
|
15 |
model = class_models.get_model(name)
|
@@ -21,11 +26,12 @@ st.title(page_title[lang])
|
|
21 |
model_name = st.selectbox(
|
22 |
model_label[lang], options=class_models.get_model_names_by_lang(lang)
|
23 |
)
|
24 |
-
title = st.text_area(title_label[lang])
|
25 |
-
|
|
|
26 |
|
27 |
if title:
|
28 |
-
input = Input(title=title, abstract=abstract)
|
29 |
model = load_class_model(model_name)
|
30 |
out = model(input)
|
31 |
st.json(out)
|
|
|
7 |
page_title = {en: "Papers classification", ru: "Классификация статей"}
|
8 |
model_label = {en: "Select model", ru: "Выберете модель"}
|
9 |
title_label = {en: "Title", ru: "Название статьи"}
|
10 |
+
authors_label = {en: "Author(s)", ru: "Автор(ы)"}
|
11 |
abstract_label = {en: "Abstract", ru: "Аннотация"}
|
12 |
|
13 |
|
14 |
+
def text_area_height(line_height: int):
|
15 |
+
return 34 * line_height
|
16 |
+
|
17 |
+
|
18 |
@st.cache_data
|
19 |
def load_class_model(name):
|
20 |
model = class_models.get_model(name)
|
|
|
26 |
model_name = st.selectbox(
|
27 |
model_label[lang], options=class_models.get_model_names_by_lang(lang)
|
28 |
)
|
29 |
+
title = st.text_area(title_label[lang], height=text_area_height(2))
|
30 |
+
authors = st.text_area(authors_label[lang], height=text_area_height(2))
|
31 |
+
abstract = st.text_area(abstract_label[lang], height=text_area_height(5))
|
32 |
|
33 |
if title:
|
34 |
+
input = Input(title=title, abstract=abstract, authors=authors)
|
35 |
model = load_class_model(model_name)
|
36 |
out = model(input)
|
37 |
st.json(out)
|
common.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
class Input:
|
2 |
-
def __init__(self, title, abstract=None):
|
3 |
self.title = title
|
4 |
self.abstract = abstract if abstract is not None else abstract
|
|
|
|
1 |
class Input:
|
2 |
+
def __init__(self, title, abstract=None, authors=None):
|
3 |
self.title = title
|
4 |
self.abstract = abstract if abstract is not None else abstract
|
5 |
+
self.authors = authors if authors is not None else ''
|