diff --git a/Makefile b/Makefile index 2aa3dc0..87d7077 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,15 @@ install: - pip install -r src/requirements.txt; cd src/client; npm install + pip install -r src/backend/requirements.txt; cd src/frontend; npm install python: - cd src; uvicorn main:app --reload + cd src/backend; uvicorn main:app --reload react: - cd src/client; npm start + cd src/frontend; npm start run-docker: - cd src; docker run -d --rm --name sherlock-back -p 8000:8000 sherlock-back; cd client; docker run -d --rm --name sherlock-front -p 3000:3000 sherlock-front + cd src/backend; docker run -d --rm --name sherlock-back -p 8000:8000 sherlock-back; cd ../frontend; docker run -d --rm --name sherlock-front -p 3000:3000 sherlock-front stop-docker: docker rmi sherlock-back; docker rmi sherlock-front diff --git a/src/.dockerignore b/src/backend/.dockerignore similarity index 100% rename from src/.dockerignore rename to src/backend/.dockerignore diff --git a/src/Dockerfile b/src/backend/Dockerfile similarity index 100% rename from src/Dockerfile rename to src/backend/Dockerfile diff --git a/src/models/__init__.py b/src/backend/__init__.py similarity index 100% rename from src/models/__init__.py rename to src/backend/__init__.py diff --git a/src/test/__init__.py b/src/backend/core/__init__.py similarity index 100% rename from src/test/__init__.py rename to src/backend/core/__init__.py diff --git a/src/models/OurKmeans.py b/src/backend/core/clustering/OurKmeans.py similarity index 99% rename from src/models/OurKmeans.py rename to src/backend/core/clustering/OurKmeans.py index 0edf0a3..f43ac39 100644 --- a/src/models/OurKmeans.py +++ b/src/backend/core/clustering/OurKmeans.py @@ -1,5 +1,6 @@ from cmath import sqrt + class OurKmeans(): def __init__(self, cluster_centers_, labels_): diff --git a/src/backend/core/clustering/__init__.py b/src/backend/core/clustering/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/models/kmeans_based_model.py b/src/backend/core/clustering/kmeans_based_model.py similarity index 97% rename from src/models/kmeans_based_model.py rename to src/backend/core/clustering/kmeans_based_model.py index a517a6e..2fe86d7 100644 --- a/src/models/kmeans_based_model.py +++ b/src/backend/core/clustering/kmeans_based_model.py @@ -1,14 +1,14 @@ -from sklearn.cluster import KMeans -from models.OurKmeans import OurKmeans -from models.dict import Dict -from models.vector_model import VectorModel +import re +import dictdatabase as ddb from collections import Counter from unidecode import unidecode -import dictdatabase as ddb -import re import matplotlib.pyplot as plt -from models.vector_model import VectorModel from sklearn.cluster import KMeans +from core.models.common.dict import Dict +from core.clustering.OurKmeans import OurKmeans +from core.models.vector_model import VectorModel +from core.models.vector_model import VectorModel + class VectorModelKMEANS(VectorModel): diff --git a/src/backend/core/feedback/__init__.py b/src/backend/core/feedback/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/models/relevance_feedback.py b/src/backend/core/feedback/relevance_feedback.py similarity index 96% rename from src/models/relevance_feedback.py rename to src/backend/core/feedback/relevance_feedback.py index 7979892..6c93309 100644 --- a/src/models/relevance_feedback.py +++ b/src/backend/core/feedback/relevance_feedback.py @@ -1,5 +1,6 @@ -from models.dict import Dict -from models.vector_model import VectorModel +from core.models.common.dict import Dict +from core.models.vector_model import VectorModel + class RelevanceFeedback: diff --git a/src/backend/core/models/__init__.py b/src/backend/core/models/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/models/base_model.py b/src/backend/core/models/base_model.py similarity index 93% rename from src/models/base_model.py rename to src/backend/core/models/base_model.py index 3d63a20..7892b13 100644 --- a/src/models/base_model.py +++ b/src/backend/core/models/base_model.py @@ -1,10 +1,8 @@ from abc import abstractmethod from typing import List, Tuple - import dictdatabase as ddb - -from models.corpus import Corpus -from models.document import Document +from core.models.common.corpus import Corpus +from core.models.common.document import Document class BaseModel: diff --git a/src/models/boolean_model.py b/src/backend/core/models/boolean_model.py similarity index 98% rename from src/models/boolean_model.py rename to src/backend/core/models/boolean_model.py index 7825297..9fd4f8f 100644 --- a/src/models/boolean_model.py +++ b/src/backend/core/models/boolean_model.py @@ -2,8 +2,8 @@ import dictdatabase as ddb from sympy import sympify from sympy.logic.boolalg import to_dnf -from models.base_model import BaseModel -from models.dict import Dict +from core.models.base_model import BaseModel +from core.models.common.dict import Dict class BooleanModel(BaseModel): diff --git a/src/backend/core/models/common/__init__.py b/src/backend/core/models/common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/models/corpus.py b/src/backend/core/models/common/corpus.py similarity index 91% rename from src/models/corpus.py rename to src/backend/core/models/common/corpus.py index 85cd6f6..d93d745 100644 --- a/src/models/corpus.py +++ b/src/backend/core/models/common/corpus.py @@ -1,9 +1,10 @@ import ir_datasets -from models.dict import Dict -from models.document import Document +from core.models.common.dict import Dict +from core.models.common.document import Document class Corpus: + def __init__(self, dataset): self.dict = Dict() self.dataset = ir_datasets.load(dataset) diff --git a/src/models/dict.py b/src/backend/core/models/common/dict.py similarity index 88% rename from src/models/dict.py rename to src/backend/core/models/common/dict.py index d0e01d2..ba24c2f 100644 --- a/src/models/dict.py +++ b/src/backend/core/models/common/dict.py @@ -1,7 +1,6 @@ -from json import JSONEncoder +class Dict: -class Dict(JSONEncoder): def __init__(self, _dict = None): self.dict = {} if _dict != None: diff --git a/src/models/document.py b/src/backend/core/models/common/document.py similarity index 94% rename from src/models/document.py rename to src/backend/core/models/common/document.py index 901466c..6156cbd 100644 --- a/src/models/document.py +++ b/src/backend/core/models/common/document.py @@ -2,10 +2,11 @@ from collections import Counter from typing import List from unidecode import unidecode -from models.dict import Dict +from core.models.common.dict import Dict class Document: + def __init__(self, doc): self.doc_id = doc.doc_id diff --git a/src/models/fuzzy_model.py b/src/backend/core/models/fuzzy_model.py similarity index 99% rename from src/models/fuzzy_model.py rename to src/backend/core/models/fuzzy_model.py index 94e09e1..7a651ea 100644 --- a/src/models/fuzzy_model.py +++ b/src/backend/core/models/fuzzy_model.py @@ -1,6 +1,6 @@ import dictdatabase as ddb from time import time -from models.boolean_model import BooleanModel +from core.models.boolean_model import BooleanModel class FuzzyModel(BooleanModel): diff --git a/src/models/vector_model.py b/src/backend/core/models/vector_model.py similarity index 97% rename from src/models/vector_model.py rename to src/backend/core/models/vector_model.py index 70fe086..8293924 100644 --- a/src/models/vector_model.py +++ b/src/backend/core/models/vector_model.py @@ -1,12 +1,12 @@ import re from math import log import dictdatabase as ddb -from models.dict import Dict +from core.models.common.dict import Dict from typing import List, Tuple from unidecode import unidecode from collections import Counter -from models.document import Document -from models.base_model import BaseModel +from core.models.common.document import Document +from core.models.base_model import BaseModel class VectorModel(BaseModel): diff --git a/src/main.py b/src/backend/main.py similarity index 89% rename from src/main.py rename to src/backend/main.py index dcdc5be..c8c4455 100644 --- a/src/main.py +++ b/src/backend/main.py @@ -1,15 +1,13 @@ from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from pydantic import BaseModel -from traitlets import FuzzyEnum -from models.kmeans_based_model import VectorModelKMEANS - -from models.boolean_model import BooleanModel -from models.corpus import Corpus -from models.fuzzy_model import FuzzyModel -from models.vector_model import VectorModel -from models.kmeans_based_model import VectorModelKMEANS -from models.relevance_feedback import RelevanceFeedback +from core.clustering.kmeans_based_model import VectorModelKMEANS +from core.models.boolean_model import BooleanModel +from core.models.common.corpus import Corpus +from core.models.fuzzy_model import FuzzyModel +from core.models.vector_model import VectorModel +from core.clustering.kmeans_based_model import VectorModelKMEANS +from core.feedback.relevance_feedback import RelevanceFeedback import dictdatabase as ddb class DocumentDto(BaseModel): diff --git a/src/requirements.txt b/src/backend/requirements.txt similarity index 61% rename from src/requirements.txt rename to src/backend/requirements.txt index 81b528b..47f92b7 100644 --- a/src/requirements.txt +++ b/src/backend/requirements.txt @@ -1,8 +1,11 @@ +os +sys +json +typing fastapi -uvicorn[standard] unidecode +matplotlib ir_datasets dictdatabase -typing scikit-learn -matplotlib \ No newline at end of file +uvicorn[standard] \ No newline at end of file diff --git a/src/backend/test/__init__.py b/src/backend/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/test/corpus_qrels.py b/src/backend/test/corpus_qrels.py similarity index 96% rename from src/test/corpus_qrels.py rename to src/backend/test/corpus_qrels.py index c777c2f..5f8cbbf 100644 --- a/src/test/corpus_qrels.py +++ b/src/backend/test/corpus_qrels.py @@ -1,6 +1,6 @@ from qrels import QRels import dictdatabase as ddb -from models.base_model import BaseModel +from core.models.base_model import BaseModel class CranfieldQRels(QRels): diff --git a/src/test/evaluation_plots.py b/src/backend/test/evaluation_plots.py similarity index 96% rename from src/test/evaluation_plots.py rename to src/backend/test/evaluation_plots.py index b4af554..d5203e0 100644 --- a/src/test/evaluation_plots.py +++ b/src/backend/test/evaluation_plots.py @@ -1,5 +1,3 @@ -import numpy as np -import matplotlib import json import matplotlib.pyplot as plt import os diff --git a/src/test/plots_evaluation_meassures.py b/src/backend/test/plots_evaluation_meassures.py similarity index 100% rename from src/test/plots_evaluation_meassures.py rename to src/backend/test/plots_evaluation_meassures.py diff --git a/src/test/qrels.py b/src/backend/test/qrels.py similarity index 99% rename from src/test/qrels.py rename to src/backend/test/qrels.py index b0ffdcd..c9ab02d 100644 --- a/src/test/qrels.py +++ b/src/backend/test/qrels.py @@ -1,7 +1,7 @@ from abc import abstractmethod import ir_datasets import dictdatabase as ddb -from models.base_model import BaseModel +from core.models.base_model import BaseModel class QRels: diff --git a/src/test/test_boolean.py b/src/backend/test/test_boolean.py similarity index 92% rename from src/test/test_boolean.py rename to src/backend/test/test_boolean.py index b34d3ad..f70cf70 100644 --- a/src/test/test_boolean.py +++ b/src/backend/test/test_boolean.py @@ -1,5 +1,5 @@ -from models.corpus import Corpus -from models.boolean_model import BooleanModel +from core.models.common.corpus import Corpus +from core.models.boolean_model import BooleanModel from corpus_qrels import CranfieldQRels, VaswaniQRels, Cord19QRels # cranfield_Corpus = Corpus('cranfield') diff --git a/src/test/test_fuzzy.py b/src/backend/test/test_fuzzy.py similarity index 88% rename from src/test/test_fuzzy.py rename to src/backend/test/test_fuzzy.py index 09560d8..2c2ad17 100644 --- a/src/test/test_fuzzy.py +++ b/src/backend/test/test_fuzzy.py @@ -1,5 +1,5 @@ -from models.corpus import Corpus -from models.fuzzy_model import FuzzyModel +from core.models.common.corpus import Corpus +from core.models.fuzzy_model import FuzzyModel from corpus_qrels import CranfieldQRels, VaswaniQRels, Cord19QRels cranfield_Corpus = Corpus('cranfield') diff --git a/src/test/test_vector.py b/src/backend/test/test_vector.py similarity index 88% rename from src/test/test_vector.py rename to src/backend/test/test_vector.py index 859bbfe..581f9b3 100644 --- a/src/test/test_vector.py +++ b/src/backend/test/test_vector.py @@ -1,5 +1,5 @@ -from models.corpus import Corpus -from models.vector_model import VectorModel +from core.models.common.corpus import Corpus +from core.models.vector_model import VectorModel from corpus_qrels import CranfieldQRels, VaswaniQRels, Cord19QRels cranfield_Corpus = Corpus('cranfield') diff --git a/src/test/test_vector_kmeans.py b/src/backend/test/test_vector_kmeans.py similarity index 76% rename from src/test/test_vector_kmeans.py rename to src/backend/test/test_vector_kmeans.py index 678f595..e36fa46 100644 --- a/src/test/test_vector_kmeans.py +++ b/src/backend/test/test_vector_kmeans.py @@ -1,7 +1,7 @@ -from models.corpus import Corpus -from models.kmeans_based_model import VectorModelKMEANS +from core.models.common.corpus import Corpus +from core.clustering.kmeans_based_model import VectorModelKMEANS from corpus_qrels import CranfieldQRels, VaswaniQRels, Cord19QRels -from models.vector_model import VectorModel +from core.models.vector_model import VectorModel # cranfield_Corpus = Corpus('cranfield') # cranfield_Vector = VectorModelKMEANS(cranfield_Corpus) diff --git a/src/client/.dockerignore b/src/frontend/.dockerignore similarity index 100% rename from src/client/.dockerignore rename to src/frontend/.dockerignore diff --git a/src/client/.gitignore b/src/frontend/.gitignore similarity index 100% rename from src/client/.gitignore rename to src/frontend/.gitignore diff --git a/src/client/Dockerfile b/src/frontend/Dockerfile similarity index 100% rename from src/client/Dockerfile rename to src/frontend/Dockerfile diff --git a/src/client/README.md b/src/frontend/README.md similarity index 100% rename from src/client/README.md rename to src/frontend/README.md diff --git a/src/client/nginx.conf b/src/frontend/nginx.conf similarity index 100% rename from src/client/nginx.conf rename to src/frontend/nginx.conf diff --git a/src/client/package-lock.json b/src/frontend/package-lock.json similarity index 100% rename from src/client/package-lock.json rename to src/frontend/package-lock.json diff --git a/src/client/package.json b/src/frontend/package.json similarity index 100% rename from src/client/package.json rename to src/frontend/package.json diff --git a/src/client/postcss.config.js b/src/frontend/postcss.config.js similarity index 100% rename from src/client/postcss.config.js rename to src/frontend/postcss.config.js diff --git a/src/client/public/favicon.ico b/src/frontend/public/favicon.ico similarity index 100% rename from src/client/public/favicon.ico rename to src/frontend/public/favicon.ico diff --git a/src/client/public/index.html b/src/frontend/public/index.html similarity index 100% rename from src/client/public/index.html rename to src/frontend/public/index.html diff --git a/src/client/public/logo192.png b/src/frontend/public/logo192.png similarity index 100% rename from src/client/public/logo192.png rename to src/frontend/public/logo192.png diff --git a/src/client/public/logo512.png b/src/frontend/public/logo512.png similarity index 100% rename from src/client/public/logo512.png rename to src/frontend/public/logo512.png diff --git a/src/client/public/manifest.json b/src/frontend/public/manifest.json similarity index 100% rename from src/client/public/manifest.json rename to src/frontend/public/manifest.json diff --git a/src/client/public/robots.txt b/src/frontend/public/robots.txt similarity index 100% rename from src/client/public/robots.txt rename to src/frontend/public/robots.txt diff --git a/src/client/public/sherlock_icon.ico b/src/frontend/public/sherlock_icon.ico similarity index 100% rename from src/client/public/sherlock_icon.ico rename to src/frontend/public/sherlock_icon.ico diff --git a/src/client/src/App.tsx b/src/frontend/src/App.tsx similarity index 100% rename from src/client/src/App.tsx rename to src/frontend/src/App.tsx diff --git a/src/client/src/components/ConfigurationModal.tsx b/src/frontend/src/components/ConfigurationModal.tsx similarity index 100% rename from src/client/src/components/ConfigurationModal.tsx rename to src/frontend/src/components/ConfigurationModal.tsx diff --git a/src/client/src/components/DialogContents.tsx b/src/frontend/src/components/DialogContents.tsx similarity index 100% rename from src/client/src/components/DialogContents.tsx rename to src/frontend/src/components/DialogContents.tsx diff --git a/src/client/src/components/DocumentDtos.tsx b/src/frontend/src/components/DocumentDtos.tsx similarity index 100% rename from src/client/src/components/DocumentDtos.tsx rename to src/frontend/src/components/DocumentDtos.tsx diff --git a/src/client/src/components/DocumentIl.css b/src/frontend/src/components/DocumentIl.css similarity index 100% rename from src/client/src/components/DocumentIl.css rename to src/frontend/src/components/DocumentIl.css diff --git a/src/client/src/components/DocumentIl.tsx b/src/frontend/src/components/DocumentIl.tsx similarity index 100% rename from src/client/src/components/DocumentIl.tsx rename to src/frontend/src/components/DocumentIl.tsx diff --git a/src/client/src/components/Loading.css b/src/frontend/src/components/Loading.css similarity index 100% rename from src/client/src/components/Loading.css rename to src/frontend/src/components/Loading.css diff --git a/src/client/src/components/Loading.tsx b/src/frontend/src/components/Loading.tsx similarity index 100% rename from src/client/src/components/Loading.tsx rename to src/frontend/src/components/Loading.tsx diff --git a/src/client/src/components/NavBar.css b/src/frontend/src/components/NavBar.css similarity index 100% rename from src/client/src/components/NavBar.css rename to src/frontend/src/components/NavBar.css diff --git a/src/client/src/components/NavBar.tsx b/src/frontend/src/components/NavBar.tsx similarity index 100% rename from src/client/src/components/NavBar.tsx rename to src/frontend/src/components/NavBar.tsx diff --git a/src/client/src/components/QueryBar.css b/src/frontend/src/components/QueryBar.css similarity index 100% rename from src/client/src/components/QueryBar.css rename to src/frontend/src/components/QueryBar.css diff --git a/src/client/src/components/QueryBar.tsx b/src/frontend/src/components/QueryBar.tsx similarity index 100% rename from src/client/src/components/QueryBar.tsx rename to src/frontend/src/components/QueryBar.tsx diff --git a/src/client/src/components/SettingsModal.tsx b/src/frontend/src/components/SettingsModal.tsx similarity index 100% rename from src/client/src/components/SettingsModal.tsx rename to src/frontend/src/components/SettingsModal.tsx diff --git a/src/client/src/components/TabsModal.tsx b/src/frontend/src/components/TabsModal.tsx similarity index 100% rename from src/client/src/components/TabsModal.tsx rename to src/frontend/src/components/TabsModal.tsx diff --git a/src/client/src/components/img/logo.png b/src/frontend/src/components/img/logo.png similarity index 100% rename from src/client/src/components/img/logo.png rename to src/frontend/src/components/img/logo.png diff --git a/src/client/src/index.tsx b/src/frontend/src/index.tsx similarity index 100% rename from src/client/src/index.tsx rename to src/frontend/src/index.tsx diff --git a/src/client/src/react-app-env.d.ts b/src/frontend/src/react-app-env.d.ts similarity index 100% rename from src/client/src/react-app-env.d.ts rename to src/frontend/src/react-app-env.d.ts diff --git a/src/client/src/setupTests.ts b/src/frontend/src/setupTests.ts similarity index 100% rename from src/client/src/setupTests.ts rename to src/frontend/src/setupTests.ts diff --git a/src/client/src/styles/globals.css b/src/frontend/src/styles/globals.css similarity index 100% rename from src/client/src/styles/globals.css rename to src/frontend/src/styles/globals.css diff --git a/src/client/tailwind.config.js b/src/frontend/tailwind.config.js similarity index 100% rename from src/client/tailwind.config.js rename to src/frontend/tailwind.config.js diff --git a/src/client/tsconfig.json b/src/frontend/tsconfig.json similarity index 100% rename from src/client/tsconfig.json rename to src/frontend/tsconfig.json