This commit is contained in:
Louai Haddad 2022-06-27 15:48:56 +02:00
parent 0c92fdfb57
commit 556d1d335f
15 changed files with 6775 additions and 6707 deletions

5
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"recommendations": [
"mkaufman.HTMLHint"
]
}

View File

@ -7,7 +7,6 @@ levels = Level.objects.all().values_list('levelNumber','levelName')
standards = Standards.objects.all().values_list('standardTitle','standardTitle')
class StandardsFilter(django_filters.FilterSet):
# level = django_filters.ModelChoiceFilter(queryset = SearchResults.objects.values('level'))
level = django_filters.MultipleChoiceFilter(choices=levels)
title = django_filters.MultipleChoiceFilter(choices=standards)
class Meta:

View File

@ -2,7 +2,7 @@ body,
p,
ul,
ol {
font-size: 14px !important;
font-size: 16px !important;
font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #454545;
letter-spacing: -0.35px;
@ -45,7 +45,7 @@ ol {
width: 30%;
}
.title a {
.title{
font-family: "Roboto Condensed", "Helvetica Neue", Helvetica, Arial, sans-serif;
line-height: 1;
text-transform: none;
@ -441,4 +441,10 @@ ol {
.dropdown-menu{
min-width: 25rem !important;
}
/* ############featured Qs########################## */
.fq{
width: 45%;
background-color: rgb(238, 238, 238);
}

View File

@ -36,7 +36,7 @@ anychart.onDocumentReady(function () {
.enabled(true)
.useHtml(true)
.text(
'Most Frequent Key-Phrases<br/>' +
'<h4>Most Frequent Key-Phrases</h4><br/>' +
'<span style="color: #575e64; font-size: 12px;">' +
'Click on words to get results' +
'</span>'

6
App/static/js/toggle.js Normal file
View File

@ -0,0 +1,6 @@
$(document).ready(function(){
$('#filterBtn').click(function(){
$child=$(this).children('i');
$child.toggleClass("fa-arrow-down").toggleClass("fa-arrow-up");
});
});

File diff suppressed because one or more lines are too long

View File

@ -48,9 +48,9 @@
<a href=""><img src="{% static 'img/un-logo-en.svg' %}" alt="United Nation" /></a>
</div>
<div class="title">
<a href="">The Integrated Disarmament
The Integrated Disarmament
Demobilization and
Reintegration Standards</a>
Reintegration Standards
</div>
<div class="search-box">
<div class="d-flex">
@ -149,6 +149,7 @@
<script src="{% static 'js/swip.js' %}"></script>
<script src="{% static 'js/filter.js' %}"></script>
<script src="{% static 'js/toggle.js' %}"></script>
<script src="https://cdn.anychart.com/releases/v8/js/anychart-base.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/js/anychart-ui.min.js"></script>

View File

@ -109,12 +109,12 @@
<div>
<div class="d-flex justify-content-between">
<div class="">
<h3>Standard: {{standard.stamdardNumber}}</h3>
<h3>IDDRS {{standard.stamdardNumber}}</h3>
<h3>{{standard.standardTitle}}</h3>
</div>
<div class="align-self-center">
{% with 'IDDRSStandards/'|add:standard.standardPath as filePath %}
<a href="{% static filePath %}" target="_blank" class="btn btn-light border rounded-3">Open Standard</a>
<a href="{% static filePath %}" target="_blank" class="btn btn-light border rounded-3">Open Module</a>
{% endwith %}
</div>
</div>

View File

@ -6,13 +6,14 @@
<div class="row justify-content-center">
<div class="col-lg-8">
<form class="d-flex align-items-center" id="searchForm" method="get">
<input type="text" class="form-control" name ="phrase" placeholder="Seach IDDRS ..." aria-label="Seach IDDRS ..." aria-describedby="basic-addon1">
<input type="text" class="form-control" name="phrase" placeholder="Seach IDDRS ..."
aria-label="Seach IDDRS ..." aria-describedby="basic-addon1">
<button id="submitSearch" type="submit" class="btn-default">Search</button>
</form>
</div>
</div>
{% if results %}
<form id="fiterForm" method="get">
<div class="d-flex justify-content-evenly mt-3">
{% for level in levels %}
@ -25,10 +26,11 @@
{% for standard in standards %}
{% if standard.standardLevel == level.levelNumber %}
<div class="form-check">
<input class="form-check-input" name="title" type="checkbox" value="{{ standard.standardTitle }}" {% if standard.standardTitle in selectedChoices %} checked {% endif %}
<input class="form-check-input" name="title" type="checkbox" value="{{ standard.standardTitle }}"
{% if standard.standardTitle in selectedChoices %} checked {% endif %}
id="checkbox{{ standard.id }}">
<label class="form-check-label" for="checkbox{{ standard.id }}">
{{ standard.standardTitle }}
{{ standard.stamdardNumber }} {{ standard.standardTitle }}
</label>
</div>
{% endif %}
@ -37,22 +39,36 @@
</div>
{% endfor %}
</div>
<input type="text" class="form-control" name ="searchedPhrase" value="{{phrase}}" hidden>
<input type="text" class="form-control" name="searchedPhrase" value="{{phrase}}" hidden>
</form>
{% endif %}
<div class="mt-5">
{% if results %}
<h4>Results for: {{ phrase }}</h4>
{% endif %}
{% if selectedChoices %}
<h5>Based on the following filter/s: <a class="text-dark" id="filterBtn" href="#filterCollapse"
data-bs-toggle="collapse" role="button" aria-expanded="false" aria-controls="filterCollapse"><i
class="fa fa-arrow-down" aria-hidden="true"></i></a></h5>
<div class="ps-5 collapse" id="filterCollapse">
{% for choice in selectedChoices %}
<h6 class="text-secondary">{{choice}}</h6>
{% endfor %}
</div>
{% endif %}
{% for result in results %}
<div class="card" data-bs-toggle="modal" data-bs-target="#staticBackdrop{{result.index}}">
<div class="card-header card-header-test1 level-text-{{ result.level|make_list|first }}">
Level {{ result.level|make_list|first }}, Standard {{result.module}}, Page {{result.pageNumber}}
Level {{ result.level|make_list|first }}, IDDRS {{result.module}}, <span class="float-end"> Page
{{result.pageNumber}} </span>
</div>
<div class="card-body">
<h5 class="card-title">
@ -66,23 +82,53 @@
{% endfor %}
</div>
{% if results %}
<nav aria-label="Page navigation example">
<ul class="pagination">
{% for i in pages.page_range %}
{% if 'title' in request.get_full_path or 'phrase' in request.get_full_path or 'searchedPhrase' in request.get_full_path %}
<li class="page-item {% if i == pNumber %} active {% endif %}"><a class="page-link" href="{{ request.get_full_path }}&page={{ i }}">{{ i }}</a></li>
{% else %}
<li class="page-item {% if i == pNumber %} active {% endif %}"><a class="page-link" href="?page={{ i }}">{{ i }}</a></li>
{% endif %}
{% for i in pages.page_range %}
{% if 'title' in request.get_full_path or 'phrase' in request.get_full_path or 'searchedPhrase' in request.get_full_path %}
<li class="page-item {% if i == pNumber %} active {% endif %}"><a class="page-link"
href="{{ request.get_full_path }}&page={{ i }}">{{ i }}</a></li>
{% else %}
<li class="page-item {% if i == pNumber %} active {% endif %}"><a class="page-link" href="?page={{ i }}">{{ i
}}</a></li>
{% endif %}
{% endfor %}
</ul>
</nav>
{% endif %}
<div id="wordCloud">
<div class="d-flex justify-content-between mt-5">
<div class="border p-2 fq" >
<h4 class="text-decoration-underline">Featured Questions About IDDRS Framework</h4>
<ul>
<li class="mb-3">
<div class="fw-bold">Featured Questions About IDDRS Framework</div>
</li>
<li class="mb-3">
<div class="fw-bold">Featured Questions About IDDRS Framework</div>
</li>
<li class="mb-3">
<div class="fw-bold">Featured Questions About IDDRS Framework</div>
</li>
<li class="mb-3">
<div class="fw-bold">Featured Questions About IDDRS Framework</div>
</li>
<li class="mb-3">
<div class="fw-bold">Featured Questions About IDDRS Framework</div>
</li>
</ul>
</div>
<div class="border" style="width: 50%;">
<div id="wordCloud">
</div>
</div>
</div>
@ -94,8 +140,9 @@
<div class="modal-content">
<div class="modal-header">
<div class="" id="staticBackdropLabel{{result.index}}">
<p class="modal-level level-text-{{ result.level|make_list|first }}">Level {{result.level}}</p>
<p class="modal-module">Standard {{result.module}}</p>
<p class="modal-level level-text-{{ result.level|make_list|first }}">Level {{result.level}} {{
result.levelName }}</p>
<p class="modal-module">IDDRS {{result.module}}</p>
<p class="modal-heading">{{result.heading1}}</p>
<p class="modal-heading modal-heading-2">{{result.heading2}}</p>
<p class="modal-heading modal-heading-3">{{result.heading3}}</p>
@ -108,7 +155,7 @@
</div>
<div class="modal-body">
<p>{{ result.paragraph|highlight_search:result.sentence|safe }}</p>
<p>{{ result.paragraph|highlight_search:result.sentence|safe|linebreaks }}</p>
<p class="text-end">Page: {{result.pageNumber}}</p>
</div>
<div class="modal-footer">
@ -120,4 +167,5 @@
{% endfor %}
{% endblock %}
{% endblock %}

View File

@ -5,7 +5,7 @@ import os
import pandas as pd
from .similarity import phrase_preprocessing, similarityCheck
from .tfidfSimilarity import cosine_similarity
import json
from django.shortcuts import redirect
from django.core.paginator import Paginator
@ -16,6 +16,8 @@ from .filters import StandardsFilter
import uuid
from datetime import date, timedelta
from django.core import serializers
# Create your views here.
@ -85,7 +87,7 @@ def tfidf(request):
else:
phrase = form.cleaned_data["phrase"]
searchResults = cosine_similarity(20, phrase)
searchResults = cosine_similarity(30, phrase)
uid = str(uuid.uuid1())[:8]+phrase
for result in searchResults:
searchedData = SearchResults(
@ -111,6 +113,7 @@ def tfidf(request):
results = SearchResults.objects.filter(uniqueID=uid)
if selectedChoices:
results = SearchResults.objects.filter(uniqueID=uid)
myFilter = StandardsFilter(request.GET, queryset=results)
@ -120,7 +123,7 @@ def tfidf(request):
form = searchForm()
# Create pagination for results
paginator = Paginator(results, per_page=5)
paginator = Paginator(results, per_page=10)
pageNumber = request.GET.get('page', 1)
page_obj = paginator.get_page(pageNumber)

Binary file not shown.