Ken Powers commited on
Commit
4ca08a4
·
unverified ·
1 Parent(s): 51892d5

Fix duplicate legend

Browse files
Files changed (1) hide show
  1. main.py +20 -18
main.py CHANGED
@@ -2065,25 +2065,9 @@ def generate_detailed_table(stats: Dict[tuple, Dict[str, Any]], max_queries: int
2065
 
2066
  markdown += "\n"
2067
 
2068
- # Add legend
2069
- markdown += "## Legend\n\n"
2070
- markdown += "- ✅ **Perfect Match** - Expected result appears as #1 result (3 points)\n"
2071
- markdown += "- ⚠️ **Good Match** - Expected result appears as #2 result (2 points)\n"
2072
- markdown += "- ❌ **Poor/No Match** - Expected result appears as #3 result (1 point) or not in top 3 (0 points)\n\n"
2073
-
2074
  return markdown
2075
 
2076
 
2077
- def generate_legend() -> str:
2078
- """Generate legend for checkmark symbols."""
2079
- return """## Legend
2080
-
2081
- - ✅ **Perfect Match** - Expected result appears as #1 result (3 points)
2082
- - ⚠️ **Good Match** - Expected result appears as #2 result (2 points)
2083
- - ❌ **Poor/No Match** - Expected result appears as #3 result (1 point) or not in top 3 (0 points)
2084
-
2085
- """
2086
-
2087
 
2088
  def generate_report(args):
2089
  """Generate markdown report and update only the Query Examples section in README.md."""
@@ -2128,6 +2112,12 @@ def generate_report(args):
2128
  print(f"README.md not found at {output_file}, creating new file")
2129
  existing_content = "# Bible Embeddings\n\n"
2130
 
 
 
 
 
 
 
2131
  # Find the Results section (or Query Examples for backward compatibility) and replace it
2132
  results_section_start = existing_content.find("## Results")
2133
  if results_section_start == -1:
@@ -2136,10 +2126,17 @@ def generate_report(args):
2136
  if results_section_start == -1:
2137
  # No Results section found, append to end
2138
  print("No existing Results section found, appending to end")
2139
- new_content = existing_content.rstrip() + "\n\n" + generate_detailed_table(stats, args.max_queries)
 
 
 
 
 
 
2140
  else:
2141
- # Find the end of the Results section (next ## heading or end of file)
2142
  next_section_start = existing_content.find("\n## ", results_section_start + 1)
 
2143
  if next_section_start == -1:
2144
  # Results is the last section
2145
  before_section = existing_content[:results_section_start]
@@ -2150,6 +2147,11 @@ def generate_report(args):
2150
 
2151
  # Replace the Results section
2152
  new_results_section = generate_detailed_table(stats, args.max_queries)
 
 
 
 
 
2153
  new_content = before_section + new_results_section + after_section
2154
 
2155
  # Write updated content to file
 
2065
 
2066
  markdown += "\n"
2067
 
 
 
 
 
 
 
2068
  return markdown
2069
 
2070
 
 
 
 
 
 
 
 
 
 
 
2071
 
2072
  def generate_report(args):
2073
  """Generate markdown report and update only the Query Examples section in README.md."""
 
2112
  print(f"README.md not found at {output_file}, creating new file")
2113
  existing_content = "# Bible Embeddings\n\n"
2114
 
2115
+ # First, remove any existing Legend sections from the content
2116
+ import re
2117
+ # Remove all Legend sections (including content until next ## section or end)
2118
+ legend_pattern = r'## Legend\n\n.*?(?=\n## |\Z)'
2119
+ existing_content = re.sub(legend_pattern, '', existing_content, flags=re.DOTALL)
2120
+
2121
  # Find the Results section (or Query Examples for backward compatibility) and replace it
2122
  results_section_start = existing_content.find("## Results")
2123
  if results_section_start == -1:
 
2126
  if results_section_start == -1:
2127
  # No Results section found, append to end
2128
  print("No existing Results section found, appending to end")
2129
+ new_results_section = generate_detailed_table(stats, args.max_queries)
2130
+ # Add legend at the end
2131
+ new_results_section += "## Legend\n\n"
2132
+ new_results_section += "- ✅ **Perfect Match** - Expected result appears as #1 result (3 points)\n"
2133
+ new_results_section += "- ⚠️ **Good Match** - Expected result appears as #2 result (2 points)\n"
2134
+ new_results_section += "- ❌ **Poor/No Match** - Expected result appears as #3 result (1 point) or not in top 3 (0 points)\n"
2135
+ new_content = existing_content.rstrip() + "\n\n" + new_results_section
2136
  else:
2137
+ # Find the end of the Results section
2138
  next_section_start = existing_content.find("\n## ", results_section_start + 1)
2139
+
2140
  if next_section_start == -1:
2141
  # Results is the last section
2142
  before_section = existing_content[:results_section_start]
 
2147
 
2148
  # Replace the Results section
2149
  new_results_section = generate_detailed_table(stats, args.max_queries)
2150
+ # Add legend at the end
2151
+ new_results_section += "## Legend\n\n"
2152
+ new_results_section += "- ✅ **Perfect Match** - Expected result appears as #1 result (3 points)\n"
2153
+ new_results_section += "- ⚠️ **Good Match** - Expected result appears as #2 result (2 points)\n"
2154
+ new_results_section += "- ❌ **Poor/No Match** - Expected result appears as #3 result (1 point) or not in top 3 (0 points)\n"
2155
  new_content = before_section + new_results_section + after_section
2156
 
2157
  # Write updated content to file