Say what each season is: the note on an estimate ends that this is the usual window, not a closure; month lists and the figures notes tell estimated from the climate and similar trails from set by judgement from pages that differ; the changelog no longer says the glossary gives the test figures
This commit is contained in:
1 parent
c3d43f41a7
commit
e6c2f371fc
12 files changed
+91
-25
No files matched your search
+11
-4
@@ -126,14 +126,21 @@ def _month_list(m):
|
||||
|
||||
def month_note(name):
|
||||
def note(recs, records):
|
||||
est = sum(1 for r in recs if facets.season_estimated(r))
|
||||
unstated = [r for r in recs if facets.season_estimated(r)]
|
||||
est = len(unstated)
|
||||
stated = len(recs) - est
|
||||
if not est:
|
||||
return f"A source states the season for all {stated}."
|
||||
kinds = {facets.season_kind(r) for r in unstated}
|
||||
one = ("estimated from the climate and similar trails" if kinds == {"estimated"}
|
||||
else "set by judgement from pages that differ" if kinds == {"judged"} else "")
|
||||
if not stated:
|
||||
return "No source states the season for these, so each is estimated from climate."
|
||||
return (f"A source states the season for {stated} of these. For the other {est} it is "
|
||||
f"estimated from climate, and marked.")
|
||||
return (f"No source states the season for these, so each is {one}." if one
|
||||
else f"No source states the season for these: {facets.season_unstated_clause(unstated)}.")
|
||||
if one:
|
||||
return f"A source states the season for {stated} of these. For the other {est} it is {one}, and marked."
|
||||
return (f"A source states the season for {stated} of these. For the other {est}, "
|
||||
f"{facets.season_unstated_clause(unstated)}, and marked.")
|
||||
return note
|
||||
|
||||
|
||||
|
||||
+24
-1
@@ -239,6 +239,27 @@ def season_pages_differ(rec):
|
||||
return season_estimated(rec) and season_basis(rec) == "sources"
|
||||
|
||||
|
||||
SEASON_USUAL = "This is the usual window, not a closure."
|
||||
|
||||
|
||||
def _plural(n, one, many):
|
||||
return f"{n} {one if n == 1 else many}"
|
||||
|
||||
|
||||
def season_unstated_clause(recs):
|
||||
"""What is true of the seasons among recs that no page states, kind by kind and counted exactly:
|
||||
"2 are estimated from the climate and similar trails and 1 is set by judgement from pages that
|
||||
differ"; "" when there are none."""
|
||||
kinds = [season_kind(r) for r in recs]
|
||||
est, judged = kinds.count("estimated"), kinds.count("judged")
|
||||
parts = []
|
||||
if est:
|
||||
parts.append(f"{est} {'is' if est == 1 else 'are'} estimated from the climate and similar trails")
|
||||
if judged:
|
||||
parts.append(f"{judged} {'is' if judged == 1 else 'are'} set by judgement from pages that differ")
|
||||
return " and ".join(parts)
|
||||
|
||||
|
||||
def season_note(rec):
|
||||
"""Says an estimated season is not a page's statement, how it was worked out, what sets it
|
||||
there and how far to trust it; "" when a page states the season."""
|
||||
@@ -247,6 +268,8 @@ def season_note(rec):
|
||||
reason = season_reason(rec)
|
||||
if season_pages_differ(rec):
|
||||
lead = "No one page states this season."
|
||||
elif "estimated from the climate" in reason:
|
||||
lead = "No page states a season." # the method says how it was estimated; not said twice
|
||||
else:
|
||||
lead = ("No page states a season. This is estimated from the climate at the trail's "
|
||||
"elevation and from similar trails.")
|
||||
@@ -256,7 +279,7 @@ def season_note(rec):
|
||||
conf = season_confidence(rec)
|
||||
if conf:
|
||||
parts.append(f"Confidence: {conf}.")
|
||||
parts.append("People do walk it outside these months.")
|
||||
parts.append(SEASON_USUAL)
|
||||
return " ".join(parts)
|
||||
|
||||
|
||||
|
||||
@@ -110,9 +110,9 @@ def season_section(records, blind):
|
||||
["Two or more pages from different publishers that agree", str(basis["sources"])],
|
||||
["One page", str(basis["source"])],
|
||||
["Pages that differ, so set by judgement from all of them", str(kinds["judged"])],
|
||||
["No page states one, so estimated from climate", str(kinds["estimated"])],
|
||||
["No page states one, so estimated from the climate and similar trails", str(kinds["estimated"])],
|
||||
["All trails", str(n)]]
|
||||
out = [f"""<p>Every trail has a season. Where a page states one, the season is that page’s. Where the pages that state one differ and none is the trail’s holder, its association or its route’s author, the season is set by judgement from all of them and the climate, and the page says so. Where no page states one, the season is estimated from the climate at the trail’s elevation and from similar trails: it reads “About” with a note, is marked in lists and is left out of the data search engines read. People do walk many trails outside their estimated months, and an estimate is replaced when a page that states a season is found.</p>
|
||||
out = [f"""<p>Every trail has a season. Where a page states one, the season is that page’s. Where the pages that state one differ and none is the trail’s holder, its association or its route’s author, the season is set by judgement from all of them and the climate, and the page says so. Where no page states one, the season is estimated from the climate at the trail’s elevation and from similar trails: it reads “About” with a note, is marked in lists and is left out of the data search engines read. An estimated season is the usual window, not a closure, and an estimate is replaced when a page that states a season is found.</p>
|
||||
{pagekit.table(["Where a trail's season comes from", "Trails"], rows, caption="Where the seasons come from", numeric=(1,))}"""]
|
||||
if blind:
|
||||
by = blind["by_confidence"]
|
||||
@@ -149,7 +149,7 @@ def method_page(records, site, repo_root):
|
||||
for label, fn in (("A usual time stated by a source", lambda r: not facets.time_days(r)[2]),
|
||||
("A season a page states", lambda r: facets.season_kind(r) == "stated"),
|
||||
("A season set from pages that differ", lambda r: facets.season_kind(r) == "judged"),
|
||||
("A season estimated from climate", lambda r: facets.season_kind(r) == "estimated"), ("A high point", lambda r: bool(hike.table(r).get("high_point_m"))),
|
||||
("A season estimated from the climate and similar trails", lambda r: facets.season_kind(r) == "estimated"), ("A high point", lambda r: bool(hike.table(r).get("high_point_m"))),
|
||||
("Terrain", lambda r: bool(facets.terrain(r))), ("What the walking is", lambda r: bool(facets.walking(r))),
|
||||
("A computed climb that covers the whole trail", lambda r: facets.row_climb_m(r) is not None),
|
||||
("A track included here", common.has_line)):
|
||||
|
||||
+3
-2
@@ -51,10 +51,11 @@ def season_cell(rec):
|
||||
def figures_note(recs):
|
||||
"""What the times and climbs of these trails mean, with the caveats the records state."""
|
||||
est = sum(1 for r in recs if facets.time_days(r)[2])
|
||||
unstated = sum(1 for r in recs if facets.season_estimated(r))
|
||||
unstated = [r for r in recs if facets.season_estimated(r)]
|
||||
parts = [f"Times that start with “About” are estimated from the length ({est} of these). "
|
||||
"Otherwise a source states the time.",
|
||||
f"Seasons that start with “About” are estimated from climate ({unstated} of these)." if unstated else "",
|
||||
(f"Seasons that start with “About” are not stated by a page ({len(unstated)} of these): "
|
||||
f"{facets.season_unstated_clause(unstated)}." if unstated else ""),
|
||||
climb_caveat(recs)]
|
||||
return " ".join(p for p in parts if p)
|
||||
|
||||
|
||||
+1
-1
@@ -149,7 +149,7 @@ def detail(rec):
|
||||
season = facets.season_text(rec)
|
||||
if season:
|
||||
how = (", judged from pages that differ" if facets.season_pages_differ(rec)
|
||||
else ", estimated from climate" if facets.season_estimated(rec) else "")
|
||||
else ", estimated from the climate and similar trails" if facets.season_estimated(rec) else "")
|
||||
out.append(f"Season: {esc(season)}{how}.")
|
||||
rest = _rest_of_summary(rec)
|
||||
if rest:
|
||||
|
||||
@@ -189,10 +189,30 @@ class SeasonTextTest(unittest.TestCase):
|
||||
note = facets.season_note(rec)
|
||||
for want in ("No page states a season", "estimated from the climate at the trail's elevation and from "
|
||||
"similar trails", "Snow keeps the high passes closed until June.", "Confidence: medium.",
|
||||
"People do walk it outside these months."):
|
||||
"This is the usual window, not a closure."):
|
||||
self.assertIn(want, note)
|
||||
self.assertNotIn("walk it outside", note)
|
||||
self.assertNotIn("Judged from", note) # the standard lead is said once, in the note's own words
|
||||
|
||||
def test_a_page_that_contradicts_itself_is_said_once_not_twice(self):
|
||||
rec = fake(1, hike=est_hike(season_method=(
|
||||
"A page was found but it contradicts itself, so no page is relied on. The season was estimated "
|
||||
"from the climate and similar trails: snow lies until June. Confidence: medium.")))
|
||||
note = facets.season_note(rec)
|
||||
self.assertTrue(note.startswith("No page states a season. A page was found but it contradicts itself"), note)
|
||||
self.assertEqual(note.count("estimated from the climate"), 1)
|
||||
self.assertTrue(note.endswith("This is the usual window, not a closure."))
|
||||
|
||||
def test_a_season_judged_from_pages_is_not_called_estimated_from_climate(self):
|
||||
judged = fake(1, hike=est_hike(season_basis="sources", season_method="The pages differ. Confidence: low."))
|
||||
est = fake(2, hike=est_hike())
|
||||
self.assertEqual(facets.season_unstated_clause([est, est, judged]),
|
||||
"2 are estimated from the climate and similar trails and 1 is set by judgement from "
|
||||
"pages that differ")
|
||||
self.assertEqual(facets.season_unstated_clause([judged]), "1 is set by judgement from pages that differ")
|
||||
self.assertEqual(facets.season_unstated_clause([est]), "1 is estimated from the climate and similar trails")
|
||||
self.assertEqual(facets.season_unstated_clause([]), "")
|
||||
|
||||
def test_a_stated_season_is_unchanged_and_has_no_note(self):
|
||||
rec = fake(1, hike={"season": "June to September", "months": [6, 7, 8, 9], "season_basis": "primary"})
|
||||
self.assertFalse(facets.season_estimated(rec))
|
||||
@@ -365,9 +385,10 @@ class BuiltVocabularyTest(unittest.TestCase):
|
||||
for rec in est[:10]:
|
||||
doc = self.read(f"trails/{rec['id']}/index.html")
|
||||
self.assertIn(facets.season_text(rec), html.unescape(doc), rec["id"])
|
||||
self.assertIn("People do walk it outside these months.", html.unescape(doc), rec["id"])
|
||||
self.assertIn("This is the usual window, not a closure.", html.unescape(doc), rec["id"])
|
||||
self.assertNotIn("outside these months", html.unescape(doc), rec["id"])
|
||||
for rec in stated[:10]:
|
||||
self.assertNotIn("People do walk it outside these months.", html.unescape(self.read(f"trails/{rec['id']}/index.html")))
|
||||
self.assertNotIn("This is the usual window", html.unescape(self.read(f"trails/{rec['id']}/index.html")))
|
||||
|
||||
def test_navigation_has_four_sections_and_saved(self):
|
||||
doc = self.read("index.html")
|
||||
|
||||
@@ -147,7 +147,8 @@ class TrailPageTest(unittest.TestCase):
|
||||
self.assertIn("Season About April to October", t)
|
||||
self.assertIn("No page states a season.", t)
|
||||
self.assertIn("Confidence: high.", t)
|
||||
self.assertIn("People do walk it outside these months.", t)
|
||||
self.assertIn("This is the usual window, not a closure.", t)
|
||||
self.assertNotIn("People do walk", t)
|
||||
self.assertIn("No source gives a season; the climate suggests about April to October.", t)
|
||||
self.assertNotIn("The usual season is", t)
|
||||
block = html.unescape(trail.hike_sources_block(rec))
|
||||
|
||||
+16
-3
@@ -138,7 +138,20 @@ class MonthListTest(unittest.TestCase):
|
||||
+ [self.est(20 + i) for i in range(5)]
|
||||
note = july.note(browse.members(july, recs), recs)
|
||||
self.assertEqual(note, "A source states the season for 10 of these. For the other 5 it is estimated "
|
||||
"from climate, and marked.")
|
||||
"from the climate and similar trails, and marked.")
|
||||
|
||||
def test_a_month_note_tells_estimated_from_judged_from_pages_that_differ(self):
|
||||
july = browse.by_key("hike-in-july")
|
||||
judged = fake(90, hike={"months": [7], "season": "July", "season_basis": "sources",
|
||||
"season_method": "The pages differ. Confidence: low."})
|
||||
stated = fake(91, hike={"months": [7], "season": "July", "season_basis": "primary"})
|
||||
recs = [stated, judged] + [self.est(20 + i) for i in range(3)]
|
||||
self.assertEqual(july.note(browse.members(july, recs), recs),
|
||||
"A source states the season for 1 of these. For the other 4, 3 are estimated from the climate "
|
||||
"and similar trails and 1 is set by judgement from pages that differ, and marked.")
|
||||
recs = [judged, judged]
|
||||
self.assertEqual(july.note(browse.members(july, recs), recs),
|
||||
"No source states the season for these, so each is set by judgement from pages that differ.")
|
||||
|
||||
def test_a_month_list_with_no_estimates_says_so(self):
|
||||
july = browse.by_key("hike-in-july")
|
||||
@@ -146,7 +159,7 @@ class MonthListTest(unittest.TestCase):
|
||||
self.assertEqual(july.note(browse.members(july, recs), recs), "A source states the season for all 10.")
|
||||
recs = [self.est(i) for i in range(3)]
|
||||
self.assertEqual(july.note(browse.members(july, recs), recs),
|
||||
"No source states the season for these, so each is estimated from climate.")
|
||||
"No source states the season for these, so each is estimated from the climate and similar trails.")
|
||||
|
||||
def test_the_month_blurb_no_longer_says_only_some_trails(self):
|
||||
group = {key: blurb for key, _title, blurb in browse.GROUPS}["month"]
|
||||
@@ -681,7 +694,7 @@ class RealDataTest(unittest.TestCase):
|
||||
kinds = {k: sum(1 for r in self.records if facets.season_kind(r) == k) for k in ("stated", "judged", "estimated")}
|
||||
self.assertEqual(sum(kinds.values()), len(self.records))
|
||||
self.assertIn(f"A season a page states Records with it {kinds['stated']} Records without {len(self.records) - kinds['stated']}", text)
|
||||
self.assertIn(f"A season estimated from climate Records with it {kinds['estimated']} Records without {len(self.records) - kinds['estimated']}", text)
|
||||
self.assertIn(f"A season estimated from the climate and similar trails Records with it {kinds['estimated']} Records without {len(self.records) - kinds['estimated']}", text)
|
||||
self.assertIn(f"A season set from pages that differ Records with it {kinds['judged']} Records without {len(self.records) - kinds['judged']}", text)
|
||||
self.assertIn(f"All trails Trails {len(self.records)}", text)
|
||||
|
||||
|
||||
Reference in new issue
Block a user