Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location and Sentence Models in Searching Documentation #63

Open
LTR14 opened this issue Jun 26, 2023 · 0 comments
Open

Location and Sentence Models in Searching Documentation #63

LTR14 opened this issue Jun 26, 2023 · 0 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@LTR14
Copy link
Collaborator

LTR14 commented Jun 26, 2023

Source: (Any branch) PPUC/PxPUC/[any filename].py, PPUC/frontend/src/components/Researchers.jsx, PPUC/scripts/add_contracts.py

Description: The location and sentence models established in PPUC/PxPUC/models.py are crucial for the search algorithm and contract pages. The general rundown of how these objects are used from the frontend to the backend:

  1. Researchers.jsx (Line 125) Makes the API call with the user’s search query
  2. api.jsx (Line 18) Creates the endpoint connection from urls.py to then be used in the frontend in JSON
  3. urls.py (Lines 57-60) Connects urls created in api.jsx to view ResearchersSearchList function in views.py
  4. views.py (Lines 233-284) This is where the bulk of the search logic is implemented. Connects with the location serializer first to establish the relationship between location and sentence. For each sentence for a given location (which has a relationship to a contract that has these sentences), get sentences that contain search query words iteratively.
    Example search query from user: “Police officer salary” -> “Police officer” -> “Police” (breaks down search string and compares it with sentences) These sentences are given ranks as well, as count is incremented, to determine which should be shown first when the time comes to display them
  5. serializers.py (Lines 8-54) Connects location serializer and sentence serializer. Location calls get_sentences with the location object data that then uses the serializer for sentences to serialize those models. This forms the relationship
  6. serializers.py (Lines 141-144) Connected sentence serializer that was used in the previous step to the sentence model in models.py
  7. models.py (Lines 62-69) Instantiates the sentence model with a relationship to the location model
  8. models.py (Lines 10-19) Instantiates the location model

These objects/models are populated from the following script:

  1. add_contracts.py (Lines 205-207) Populates the locations based on text file names of the contracts at PPUC/PxPUC/static/app/{any}.txt
  2. add_contracts.py (Lines 220-222) Populates the contract models with the location from step one
  3. add_contracts.py (Lines 246-248) Populates the sentence models within the contract in step two from the location in step one.

Additional Notes: https://docs.google.com/document/d/1ixJNlHZgvns8YmCt1Nk1t2sfYvMRkp8a9VZyP2NUJek/edit?usp=sharing

https://docs.google.com/document/d/1Qrdd_ZCrckT_slLfsI6t-UZ8JcrhZFO-4uf5KISCqo0/edit

Video Notes: https://drive.google.com/file/d/1_nIiSDXGQ5ZMT-HfuwKbO1nfPPeUl_3s/view?usp=drive_link

@LTR14 LTR14 added documentation Improvements or additions to documentation good first issue Good for newcomers labels Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant