Абалдеть, как будто бы сделал фулл

This commit is contained in:
maksim 2024-06-06 23:37:38 +04:00
parent a41dae920f
commit 04a5f4b4b5
6 changed files with 43 additions and 2 deletions

View File

@ -89,7 +89,7 @@ def path_length_and_time(path, graph):
return float('inf'), start_time, end_time
length += graph[path[i]][path[i + 1]][0]
if i > 0: # Пропуск первой вершины
if end_time + timedelta(minutes=5) > graph[path[i]][path[i + 1]][1]:
if end_time + timedelta(minutes=180) > graph[path[i]][path[i + 1]][1]:
return float('inf'), start_time, end_time # Неприемлемый путь
end_time = graph[path[i]][path[i + 1]][2]
return length, start_time, end_time

View File

@ -6,6 +6,7 @@ from database import create_tables, delete_tables
from router_questions import router as questions_router
from router_class import router as class_router
from router_flight import router as flight_router
from router_reviews import router as reviews_router
# Настройка логирования
logging.basicConfig(level=logging.INFO)
@ -24,4 +25,5 @@ app = FastAPI(lifespan=lifespan)
app.include_router(questions_router)
app.include_router(class_router)
app.include_router(flight_router)
app.include_router(reviews_router)

Binary file not shown.

View File

@ -1,6 +1,9 @@
import pandas as pd
from fastapi import APIRouter
from typing import List
from enums import TypeMood
from schemas import Review
router = APIRouter(
prefix="/class",
@ -19,3 +22,6 @@ async def get_class_names() -> List[str]:
with open(".//neural_network/classification/class_names_positive.txt", "r", encoding="utf-8") as file:
class_names = [line.strip() for line in file.readlines()]
return class_names

28
router_reviews.py Normal file
View File

@ -0,0 +1,28 @@
import pandas as pd
from fastapi import APIRouter
from typing import List
from enums import TypeMood
from schemas import Review
router = APIRouter(
prefix="/reviews",
tags=["Reviews"],
)
@router.get("/{rubrics}")
def get_reviews(rubrics: str,
type_mood: TypeMood) -> list[Review]:
if type_mood == TypeMood.NEGATIVE:
df = pd.read_csv("./sity/sity_negative.csv")
else:
df = pd.read_csv("./sity/sity_positive.csv")
df = df.fillna("")
filtered_df = df[df["rubrics"] == rubrics]
shuffled_df = filtered_df.sample(frac=1)
sorted_df = shuffled_df.sort_values(by="rating", ascending=False)
unique_reviews = sorted_df.drop_duplicates(subset="city")
unique_reviews = unique_reviews.head(10).to_dict(orient="records")
return unique_reviews

View File

@ -39,3 +39,8 @@ class TripRequest(BaseModel):
returnDate: Optional[str] = None
flightsTo: List[Flight]
flightsBack: List[Flight]
class Review(BaseModel):
city: str
address: str
name_ru: str