@@ -35,6 +35,7 @@ class Score:
3535 literate : float
3636 output : float
3737 navigation : float
38+ graph : float
3839 layout : float
3940
4041
@@ -87,19 +88,21 @@ def score_python_example(example: dict) -> Score:
8788
8889 output = 1.0 if example .get ("expected_output" ) is not None and "white-space: pre-wrap" in PROJECT_SURFACE and "overflow-wrap: anywhere" in PROJECT_SURFACE else 0.4
8990 navigation = 1.0 if "rel=\" prev\" " in PROJECT_SURFACE and "rel=\" next\" " in PROJECT_SURFACE and "docs.python.org/3.13/" in example .get ("doc_url" , "" ) else 0.5
91+ see_also = example .get ("see_also" , [])
92+ graph = 0.3 if see_also and "see-also-label" in PROJECT_SURFACE else 0.0
9093 layout = 1.0
9194 if "class=\" pill\" " in PROJECT_SURFACE or "corner" in PROJECT_SURFACE or "border-radius: 999px; color: inherit" in PROJECT_SURFACE :
9295 layout -= 0.4
9396 if "nav a { color: inherit; text-decoration: underline" not in PROJECT_SURFACE :
9497 layout -= 0.2
95- total = round (max (0 , payoff + deterministic + idiom + literate + output + navigation + layout ), 2 )
96- return Score (example ["slug" ], total , payoff , deterministic , idiom , literate , output , navigation , max (0 , layout ))
98+ total = round (max (0 , payoff + deterministic + idiom + literate + output + navigation + graph + layout ), 2 )
99+ return Score (example ["slug" ], total , payoff , deterministic , idiom , literate , output , navigation , graph , max (0 , layout ))
97100
98101
99102def score_external_literate_page (name : str , url : str , language_markers : tuple [str , ...], reference_label : str ) -> Score :
100103 text = _fetch_text (url )
101104 if not text :
102- return Score (name , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
105+ return Score (name , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
103106 words = text .split ()
104107 payoff = 1.8 if len (words ) > 220 else 1.5
105108 deterministic = 1.1 if any (marker in text for marker in ["Run" , "Playground" , "$ go run" , "go run" ]) else 0.8
@@ -110,7 +113,7 @@ def score_external_literate_page(name: str, url: str, language_markers: tuple[st
110113 navigation = 0.8 if any (marker in text for marker in ["Next" , "Previous" , "Rust By Example" , "Go by Example" ]) else 0.4
111114 layout = 1.0
112115 total = round (payoff + deterministic + idiom + literate + output + navigation + layout , 2 )
113- return Score (name , total , payoff , deterministic , idiom , literate , output , navigation , layout )
116+ return Score (name , total , payoff , deterministic , idiom , literate , output , navigation , 0.0 , layout )
114117
115118
116119def score_gobyexample_page (slug : str ) -> Score :
@@ -123,9 +126,9 @@ def score_rust_by_example_page(slug: str) -> Score:
123126
124127def print_table (title : str , scores : list [Score ]) -> None :
125128 print (f"\n { title } " )
126- print ("name,total,payoff,deterministic,idiom,literate,output,navigation,layout" )
129+ print ("name,total,payoff,deterministic,idiom,literate,output,navigation,graph, layout" )
127130 for s in scores :
128- print (f"{ s .name } ,{ s .total :.2f} ,{ s .payoff :.1f} ,{ s .deterministic :.1f} ,{ s .idiom :.1f} ,{ s .literate :.1f} ,{ s .output :.1f} ,{ s .navigation :.1f} ,{ s .layout :.1f} " )
131+ print (f"{ s .name } ,{ s .total :.2f} ,{ s .payoff :.1f} ,{ s .deterministic :.1f} ,{ s .idiom :.1f} ,{ s .literate :.1f} ,{ s .output :.1f} ,{ s .navigation :.1f} ,{ s .graph :.1f } , { s . layout :.1f} " )
129132 print (f"average,{ mean (s .total for s in scores ):.2f} " )
130133
131134
0 commit comments