Абалдеть, как будто бы сделал фулл
This commit is contained in:
parent
a41dae920f
commit
04a5f4b4b5
@ -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
|
||||
|
2
main.py
2
main.py
@ -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)
|
||||
|
||||
|
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
@ -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
28
router_reviews.py
Normal 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
|
||||
|
||||
|
@ -38,4 +38,9 @@ class TripRequest(BaseModel):
|
||||
departureDate: str
|
||||
returnDate: Optional[str] = None
|
||||
flightsTo: List[Flight]
|
||||
flightsBack: List[Flight]
|
||||
flightsBack: List[Flight]
|
||||
|
||||
class Review(BaseModel):
|
||||
city: str
|
||||
address: str
|
||||
name_ru: str
|
Loading…
Reference in New Issue
Block a user