@@ -126,33 +126,36 @@ def process_coveo_meta(meta, url, link):
126
126
if tag_name == 'ovdoctype' :
127
127
ET .SubElement (namespace_element , tag_name ).text = process_link (link )
128
128
elif tag_name == 'ovcategory' and loc_element is not None :
129
- ET .SubElement (namespace_element , tag_name ).text = extract_hierarchy (loc_element .text )
129
+ ET .SubElement (namespace_element , tag_name ).text = extract_categories (loc_element .text )
130
130
elif tag_name == 'ovversion' :
131
131
ET .SubElement (namespace_element , tag_name ).text = tag_value
132
132
133
133
def process_link (link ):
134
134
if '/' in link :
135
- return link .split ('/' )[0 ].replace ("-" , " " )
136
- return link .split ('.html' )[0 ].replace ("-" , " " )
135
+ return format_segment ( link .split ('/' )[0 ].replace ("-" , " " ) )
136
+ return format_segment ( link .split ('.html' )[0 ].replace ("-" , " " ) )
137
137
138
- def extract_hierarchy (link ):
138
+ def extract_categories (link ):
139
139
path = link .split ("://" )[- 1 ]
140
140
segments = path .split ('/' )[1 :]
141
141
if segments and segments [- 1 ].endswith ('.html' ):
142
142
segments = segments [:- 1 ]
143
143
144
+ if segments :
145
+ segments = segments [1 :]
146
+
144
147
if segments and '.' in segments [0 ]:
145
148
year , * rest = segments [0 ].split ('.' )
146
149
if year .isdigit () and len (year ) == 4 :
147
150
segments [0 ] = year
148
151
149
152
segments = [format_segment (segment ) for segment in segments ]
150
153
151
- hierarchy = []
152
- for i in range (1 , len (segments ) + 1 ):
153
- hierarchy . append ( '| ' .join (segments [: i ]) )
154
-
155
- return ';' . join ( hierarchy )
154
+ if segments :
155
+ hierarchy = [ '|' . join ( segments [: i ]) for i in range (1 , len (segments ) + 1 )]
156
+ return '; ' .join (hierarchy )
157
+
158
+ return "No category"
156
159
157
160
def format_segment (segment ):
158
161
if segment == 'c_cpp_api' : segment = 'C/C++_api'
0 commit comments