Skip to content

Commit

Permalink
fix church_id not null
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennecallies committed Sep 30, 2024
1 parent cc25f77 commit d4460ef
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 23 deletions.
2 changes: 1 addition & 1 deletion home/templates/pages/moderate_parsing.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h2 class="mb-3">

Church description by id : <pre>{{ church_desc_by_id_json }}</pre><br>
Truncated html :
<div class="truncated-html-tabs">
<div class="moderation-tabs">
<ul>
<li><a href="#tabs-nice">Nice display</a></li>
<li><a href="#tabs-raw">Raw HTML</a></li>
Expand Down
49 changes: 29 additions & 20 deletions home/templates/partials/schedules_display.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
{% load custom_tags %}
{% load display_tags %}

<div>
{% for schedule in schedules_list.schedules %}
church_id: {{ schedule.church_id }}<br>
rrule: {{ schedule.rrule }}<br>
duration_in_minutes: {{ schedule.duration_in_minutes }}<br>
include_periods: {{ schedule.include_periods }}<br>
exclude_periods: {{ schedule.exclude_periods }}<br>
{% with events=schedule|get_schedule_item_events %}
{% for event in events %}
<p>{% display_event event %}</p>
{% endfor %}
{% endwith %}
<br>
{% endfor %}
possible_by_appointment: {{ schedules_list.possible_by_appointment }}<br>
is_related_to_mass: {{ schedules_list.is_related_to_mass }}<br>
is_related_to_adoration: {{ schedules_list.is_related_to_adoration }}<br>
is_related_to_permanence: {{ schedules_list.is_related_to_permanence }}<br>
will_be_seasonal_events: {{ schedules_list.will_be_seasonal_events }}<br>
</div>
<div class="moderation-tabs">
<ul>
<li><a href="#tabs-nice-display">Nice display</a></li>
<li><a href="#tabs-raw-json">Raw JSON</a></li>
</ul>
<div id="tabs-nice-display">
{% for schedule in schedules_list.schedules %}
church_id: {{ schedule.church_id }}<br>
rrule: {{ schedule.rrule }}<br>
duration_in_minutes: {{ schedule.duration_in_minutes }}<br>
include_periods: {{ schedule.include_periods }}<br>
exclude_periods: {{ schedule.exclude_periods }}<br>
{% with events=schedule|get_schedule_item_events %}
{% for event in events %}
<p>{% display_event event %}</p>
{% endfor %}
{% endwith %}
<br>
{% endfor %}
possible_by_appointment: {{ schedules_list.possible_by_appointment }}<br>
is_related_to_mass: {{ schedules_list.is_related_to_mass }}<br>
is_related_to_adoration: {{ schedules_list.is_related_to_adoration }}<br>
is_related_to_permanence: {{ schedules_list.is_related_to_permanence }}<br>
will_be_seasonal_events: {{ schedules_list.will_be_seasonal_events }}<br>
</div>
<div id="tabs-raw-json">
<pre>{{ schedules_list_json }}</pre>
</div>
</div>
5 changes: 4 additions & 1 deletion home/templatetags/display_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@ def display_similar_churches_location(church: Church, sorted_similar_churches: l

@register.simple_tag
def display_schedules_list(schedules_list: SchedulesList):
return render_to_string('partials/schedules_display.html', {'schedules_list': schedules_list})
return render_to_string('partials/schedules_display.html', {
'schedules_list': schedules_list,
'schedules_list_json': schedules_list.model_dump_json(),
})
1 change: 1 addition & 0 deletions scraping/parse/parse_with_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def get_prompt_template():
or "avant Pâques") or a precise time (e.g. "dans la matinée" or "dans la soirée"), do not return
a schedule item dictionary for this event. Usually, it means some of the booleans for mass,
adoration, permanence or seasonal events should be set to True.
- If the church is not explicit in the text, the church_id must be null.
Here is the HTML extract to parse:
{truncated_html}
Expand Down
Binary file modified scraping/tests/fixtures/parse/llm_cache.cache
Binary file not shown.
5 changes: 5 additions & 0 deletions scraping/tests/fixtures/parse/stnomdejesus.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Rencontrer un prêtre - Se confesser<br>
Mardi<br>
Samedi<br>
18:00 - 19:00<br>
10:00 - 12:00
34 changes: 34 additions & 0 deletions scraping/tests/fixtures/parse/stnomdejesus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"input": {
"church_desc_by_id": {
"1": "Chapelle du Saint-Nom-de-J\u00e9sus Lyon",
"2": "\u00c9glise du Saint-Nom-de-J\u00e9sus Lyon"
},
"year": 2024
},
"output": {
"schedules_list": {
"schedules": [
{
"church_id": null,
"rrule": "DTSTART:20240102T180000\nRRULE:FREQ=WEEKLY;BYDAY=TU",
"duration_in_minutes": 60,
"include_periods": [],
"exclude_periods": []
},
{
"church_id": null,
"rrule": "DTSTART:20240106T100000\nRRULE:FREQ=WEEKLY;BYDAY=SA",
"duration_in_minutes": 120,
"include_periods": [],
"exclude_periods": []
}
],
"possible_by_appointment": false,
"is_related_to_mass": false,
"is_related_to_adoration": false,
"is_related_to_permanence": false,
"will_be_seasonal_events": false
}
}
}
1 change: 1 addition & 0 deletions scraping/tests/tests_llm_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def get_paragraphs_fixtures():
'azergues',
'garches',
'houilles',
'stnomdejesus',
]

def test_llm_parsing(self):
Expand Down
2 changes: 1 addition & 1 deletion static/js/moderation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
* Requires JQuery UI Tabs.
*/
$( function() {
$( ".truncated-html-tabs" ).tabs();
$( ".moderation-tabs" ).tabs();
} );

0 comments on commit d4460ef

Please sign in to comment.