Spaces:
Runtime error
Runtime error
Update stri.py
Browse files
stri.py
CHANGED
|
@@ -18,28 +18,28 @@ model = AutoModel.from_pretrained(model_name, output_hidden_states=True)
|
|
| 18 |
|
| 19 |
# Загрузка датасета и аннотаций к книгам
|
| 20 |
books = pd.read_csv('all+++.csv')
|
| 21 |
-
books.dropna(inplace=True)
|
| 22 |
|
| 23 |
-
books = books[books['annotation'].apply(lambda x: len(x.split()) >= 40)]
|
| 24 |
-
books.drop_duplicates(subset='title', keep='first', inplace=True)
|
| 25 |
-
books = books.reset_index(drop=True)
|
| 26 |
|
| 27 |
|
| 28 |
-
def data_preprocessing(text: str) -> str:
|
| 29 |
-
text = re.sub(r'http\S+', " ", text) # удаляем ссылки
|
| 30 |
-
text = re.sub(r'@\w+', ' ', text) # удаляем упоминания пользователей
|
| 31 |
-
text = re.sub(r'#\w+', ' ', text) # удаляем хэштеги
|
| 32 |
-
text = re.sub(r'<.*?>', ' ', text) # html tags
|
| 33 |
-
|
| 34 |
|
| 35 |
|
| 36 |
-
for i in ['author', 'title', 'annotation']:
|
| 37 |
-
books[i] = books[i].apply(data_preprocessing)
|
| 38 |
|
| 39 |
annot = books['annotation']
|
| 40 |
|
| 41 |
# Получение эмбеддингов аннотаций каждой книги в датасете
|
| 42 |
-
length =
|
| 43 |
|
| 44 |
# Определение запроса пользователя
|
| 45 |
query = st.text_input("Введите запрос")
|
|
|
|
| 18 |
|
| 19 |
# Загрузка датасета и аннотаций к книгам
|
| 20 |
books = pd.read_csv('all+++.csv')
|
| 21 |
+
#books.dropna(inplace=True)
|
| 22 |
|
| 23 |
+
#books = books[books['annotation'].apply(lambda x: len(x.split()) >= 40)]
|
| 24 |
+
#books.drop_duplicates(subset='title', keep='first', inplace=True)
|
| 25 |
+
#books = books.reset_index(drop=True)
|
| 26 |
|
| 27 |
|
| 28 |
+
#def data_preprocessing(text: str) -> str:
|
| 29 |
+
#text = re.sub(r'http\S+', " ", text) # удаляем ссылки
|
| 30 |
+
#text = re.sub(r'@\w+', ' ', text) # удаляем упоминания пользователей
|
| 31 |
+
#text = re.sub(r'#\w+', ' ', text) # удаляем хэштеги
|
| 32 |
+
#text = re.sub(r'<.*?>', ' ', text) # html tags
|
| 33 |
+
# return text
|
| 34 |
|
| 35 |
|
| 36 |
+
#for i in ['author', 'title', 'annotation']:
|
| 37 |
+
#books[i] = books[i].apply(data_preprocessing)
|
| 38 |
|
| 39 |
annot = books['annotation']
|
| 40 |
|
| 41 |
# Получение эмбеддингов аннотаций каждой книги в датасете
|
| 42 |
+
length = 256
|
| 43 |
|
| 44 |
# Определение запроса пользователя
|
| 45 |
query = st.text_input("Введите запрос")
|