Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ DB_NAME=leadme

# MONGO
MONGO_DB_NAME=highfive
MONGO_DB_HOST=1232132131
MONGO_DB_PORT=123213
MONGO_DB_HOST=localhost
MONGO_DB_PORT=27017

# Word2Vec Model path
W2V_MODEL_PATH=./app/models/GoogleNews-vectors-negative300.bin
W2V_MODEL_PATH=./app/models/node2vec.model

# RabbitMQ
RABBITMQ_URL=localhost
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
echo "DB_PASSWORD=testpass" >> .env.local
echo "DB_NAME=testdb" >> .env.local
echo "W2V_MODEL_PATH=./app/assets/word2vec.model" >> .env.local
echo "MONGO_URL=mongodb://localhost:27017" >> .env.local
echo "RABBITMQ_URL=localhost" >> .env.local
echo "RABBITMQ_PORT=5672" >> .env.local
echo "DEV_REDIS_HOST=localhost" >> .env.local
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ __pycache__/
*.log

# w2v 모델
GoogleNews-vectors-negative300.bin.gz
GoogleNews-vectors-negative300.bin.gz
node2vec.model
15 changes: 12 additions & 3 deletions app/models/db_w2v_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"가족": "Family",
"코미디": "Comedy",
"애니메이션": "Animation",
"SF": "SF",
"SF": "Science Fiction",
"다큐멘터리": "Documentary",
"판타지": "Fantasy",
"드라마": "Drama",
Expand All @@ -24,5 +24,14 @@
}


def translate_genre(korean_genre: str) -> str:
return _genre_mapping.get(korean_genre, korean_genre)
def translate_genre(genre: str) -> str | None:
genre = genre.strip()

if genre in _genre_mapping:
return _genre_mapping[genre]

if genre in _genre_mapping.values():
return genre

return None

6 changes: 3 additions & 3 deletions app/models/word2vec_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from gensim.models import KeyedVectors
from gensim.models import Word2Vec


class Word2VecModel:
Expand All @@ -8,15 +8,15 @@ class Word2VecModel:
def load_model(cls, model_path: str):
if cls._model is None:
print("모델 로딩 중...")
cls._model = KeyedVectors.load_word2vec_format(model_path, binary=True)
cls._model = Word2Vec.load(model_path)
print("모델 로드 완료!")
return cls._model

@classmethod
def get_vector(cls, word: str):
if cls._model is None:
raise RuntimeError("모델이 아직 로드되지 않았습니다.")
return cls._model.get_vector(word)
return cls._model.wv.get_vector(word)

@classmethod
def similarity(cls, word1: str, word2: str) -> float:
Expand Down
Empty file removed app/tests/__init__.py
Empty file.
21 changes: 0 additions & 21 deletions app/tests/test_embedding_router.py

This file was deleted.

23 changes: 0 additions & 23 deletions app/tests/test_embedding_service.py

This file was deleted.