-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
418 additions
and
10,606 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
__pycache__/ | ||
/scripts/ | ||
*.sql | ||
*.ipynb |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Code developed during SCT 18 hackathon | ||
import re | ||
import urllib.request | ||
|
||
import pandas as pd | ||
from nltk.corpus import stopwords | ||
from nltk.tokenize import word_tokenize | ||
|
||
res = "C:\\Users\\Don\\PycharmProjects\\Zalando_Hackathon\\Res\\" | ||
|
||
# download if needed | ||
# nltk.download('stopwords', res + "nltk") | ||
# nltk.download('punkt', res + "nltk") | ||
|
||
input_text = "I'm working on a WASH project in a refugee camp and we are improving hygiene practices and access to safe, clean water." | ||
# input_text = "I'm working on a USG funded program in education and I would like to track students enrolled in courses" | ||
# input_text = "I am looking for an output indicator that let's me track who is knowledgable about the gender practices" | ||
|
||
stop_words = set(stopwords.words('english')) | ||
|
||
word_tokens_input = word_tokenize(input_text.lower()) | ||
filtered_sentence_input = [w for w in word_tokens_input if w not in stop_words] | ||
|
||
correlations = [] | ||
|
||
csv_data = pd.read_csv("indicator_new.csv") | ||
# print(csv_data.columns) | ||
for i in range(1, 2055): # TODO: | ||
# for i in range(460, 470): # TODO: | ||
data = csv_data[csv_data["id"] == i] | ||
# print(i) | ||
indicator = "" | ||
if not pd.isna(csv_data["Indicator"].iloc[i]): | ||
indicator += csv_data["Indicator"].iloc[i] | ||
if not pd.isna(csv_data["Sector"].iloc[i]): | ||
indicator += csv_data["Sector"].iloc[i] | ||
if not pd.isna(csv_data["Definition"].iloc[i]): | ||
indicator += csv_data["Definition"].iloc[i] | ||
indicator = re.sub(r'[^0-9a-z ]+', '', indicator.lower()) | ||
word_tokens_indicator = word_tokenize(indicator) | ||
filtered_sentence_indicator = [w for w in word_tokens_indicator if w not in stop_words] | ||
|
||
correlation = [(w, filtered_sentence_input.count(w)) for w in filtered_sentence_input if w in filtered_sentence_indicator] | ||
correlation = set(correlation) | ||
# print(correlation) | ||
score = 0 | ||
for w, count in correlation: | ||
count *= filtered_sentence_indicator.count(w) | ||
score += count | ||
# score = len(correlation) # Perhaps a better score? | ||
correlations.append({"id": i, "score": score}) | ||
|
||
|
||
print(correlations) | ||
sorted_correlations = sorted(correlations, key=lambda x: x["score"], reverse=True) | ||
print(sorted_correlations) | ||
print(input_text) | ||
|
||
for i in range(min(10, len(sorted_correlations))): | ||
id = sorted_correlations[i]["id"] | ||
print(i+1, "(%d)" % sorted_correlations[i]["score"], "-", csv_data["Indicator"].iloc[id]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
{% block content %}{% endblock %} | ||
{% block pagination %} | ||
{% if is_paginated %} | ||
<div class="pagination"> | ||
{% if is_paginated %} | ||
<div class="pagination"> | ||
<span class="page-links"> | ||
{% if page_obj.has_previous %} | ||
<a href="{{ request.path }}?page={{ page_obj.previous_page_number }}">previous</a> | ||
<a href="{{ request.path }}?page={{ page_obj.previous_page_number }}">previous</a> | ||
{% endif %} | ||
<span class="page-current"> | ||
<span class="page-current"> | ||
<p>Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.</p> | ||
</span> | ||
{% if page_obj.has_next %} | ||
<a href="{{ request.path }}?page={{ page_obj.next_page_number }}">next</a> | ||
{% endif %} | ||
{% if page_obj.has_next %} | ||
<a href="{{ request.path }}?page={{ page_obj.next_page_number }}">next</a> | ||
{% endif %} | ||
</span> | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% endif %} | ||
{% endblock %} |
10 changes: 5 additions & 5 deletions
10
indicatorlibrary/quickstart/templates/quickstart/Profile.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{% extends 'base.html' %} | ||
{% block content %} | ||
<div class="container-fluid"> | ||
<h2>User Profile</h2> | ||
<p>Username: {{ user }}</p> | ||
<p>Email : {{ user.email }}</p> | ||
<p>First name: {{ user.first_name }}</p> | ||
<p>Org: {{ user.profile.organization }}</p> | ||
<h2>User Profile</h2> | ||
<p>Username: {{ user }}</p> | ||
<p>Email : {{ user.email }}</p> | ||
<p>First name: {{ user.first_name }}</p> | ||
<p>Org: {{ user.profile.organization }}</p> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{% extends 'base.html' %} | ||
{% block content %} | ||
<p><label href="https://toladata.com">TolaData</label> is supporting an open source project called the Indicator Library, which started as an exercise to collect and compile nearly 2,500 commonly used indicators used by NGOs and donors in the international development and humanitarian sector as well as to include indicators used for corporate reporting on the SDGs. | ||
<br> | ||
The project’s goal is to improve the use of indicators by promoting standard, reusable indicators alongside guidance to help users effectively plan and collect useful data for their projects.</p> | ||
<br> | ||
The project’s goal is to improve the use of indicators by promoting standard, reusable indicators alongside guidance to help users effectively plan and collect useful data for their projects.</p> | ||
{% endblock %} |
32 changes: 16 additions & 16 deletions
32
indicatorlibrary/quickstart/templates/quickstart/add_indicator.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
{% extends 'base.html' %} | ||
{% block content %} | ||
<h2>Add your own indicator</h2> | ||
<form method="post"> | ||
{% csrf_token %} | ||
{% for field in form %} | ||
<p> | ||
{{ field.label_tag }}<br> | ||
{{ field }} | ||
{% if field.help_text %} | ||
<small style="color: grey">{{ field.help_text }}</small> | ||
{% endif %} | ||
{% for error in field.errors %} | ||
<p style="color: red">{{ error }}</p> | ||
<h2>Add your own indicator</h2> | ||
<form method="post"> | ||
{% csrf_token %} | ||
{% for field in form %} | ||
<p> | ||
{{ field.label_tag }}<br> | ||
{{ field }} | ||
{% if field.help_text %} | ||
<small style="color: grey">{{ field.help_text }}</small> | ||
{% endif %} | ||
{% for error in field.errors %} | ||
<p style="color: red">{{ error }}</p> | ||
{% endfor %} | ||
</p> | ||
{% endfor %} | ||
</p> | ||
{% endfor %} | ||
<button type="submit">Submit</button> | ||
</form> | ||
<button type="submit">Submit</button> | ||
</form> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 28 additions & 28 deletions
56
indicatorlibrary/quickstart/templates/quickstart/indilist.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block content %} | ||
{% block content %} | ||
|
||
|
||
<form method="get"> | ||
{{ filter.form.as_p }} | ||
<button type="submit" class="btn btn-secondary">Search</button> | ||
</form> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th scope="col">#</th> | ||
<th scope="col">Indicator ID</th> | ||
<th scope="col">Name</th> | ||
<th scope="col">Level</th> | ||
<th scope="col">Sector</th> | ||
<th scope="col">JSON API</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<form method="get"> | ||
{{ filter.form.as_p }} | ||
<button type="submit" class="btn btn-secondary">Search</button> | ||
</form> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th scope="col">#</th> | ||
<th scope="col">Indicator ID</th> | ||
<th scope="col">Name</th> | ||
<th scope="col">Level</th> | ||
<th scope="col">Sector</th> | ||
<th scope="col">JSON API</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
|
||
{% for indicator in filter.qs %} | ||
<td> | ||
<th scope="row">{{ indicator.id }}</th> | ||
<td> <a href="{{indicator.id}} ">{{indicator.name}}</a></td> | ||
<td>{{indicator.level}}</td> | ||
<td>{{indicator.sector}}</td> | ||
<td><a href="http://indilib.herokuapp.com/indicator/{{ indicator.id}}/?format=json"><strong>Json API:</strong> http://indilib.herokuapp.com/indicator/{{ indicator.id}}/?format=json</a></td> | ||
</tr> | ||
{% for indicator in filter.qs %} | ||
<td> | ||
<th scope="row">{{ indicator.id }}</th> | ||
<td> <a href="{{indicator.id}} ">{{indicator.name}}</a></td> | ||
<td>{{indicator.level}}</td> | ||
<td>{{indicator.sector}}</td> | ||
<td><a href="http://indilib.herokuapp.com/indicator/{{ indicator.id}}/?format=json"><strong>Json API:</strong> http://indilib.herokuapp.com/indicator/{{ indicator.id}}/?format=json</a></td> | ||
</tr> | ||
|
||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
|
||
{% endblock %} |
Oops, something went wrong.