equal
deleted
inserted
replaced
220 res = [] |
220 res = [] |
221 |
221 |
222 for t in qslist: |
222 for t in qslist: |
223 if hasattr(t, 'dbpedia_fields'): |
223 if hasattr(t, 'dbpedia_fields'): |
224 dbfields = t.dbpedia_fields |
224 dbfields = t.dbpedia_fields |
225 resobj = {'original_label':t.label, 'url':t.dbpedia_uri} |
225 resobj = {'original_label':t.label, 'url':t.wikipedia_url} |
226 if count_notices_bool: |
226 if count_notices_bool: |
227 resobj['nb'] = t.nb |
227 resobj['nb'] = t.nb |
228 resobj['thumbnail'] = dbfields.thumbnail if dbfields is not None else None |
228 resobj['thumbnail'] = dbfields.thumbnail if dbfields is not None else None |
229 |
229 |
230 if t.id in translations: |
230 if t.id in translations: |
379 contenus[ts.datasheet_id]['tags'].append({'id': ts.tag.id, |
379 contenus[ts.datasheet_id]['tags'].append({'id': ts.tag.id, |
380 'label': ts.tag.label, |
380 'label': ts.tag.label, |
381 'order': ts.order, |
381 'order': ts.order, |
382 'match': match_tag, |
382 'match': match_tag, |
383 'translated_label': translations.get(ts.tag.dbpedia_fields.id, ts.tag.label) if ts.tag.dbpedia_fields is not None else ts.tag.label, |
383 'translated_label': translations.get(ts.tag.dbpedia_fields.id, ts.tag.label) if ts.tag.dbpedia_fields is not None else ts.tag.label, |
384 'url': ts.tag.dbpedia_uri}) |
384 'url': ts.tag.dbpedia_uri, |
|
385 'wkpd_url': ts.tag.wikipedia_url}) |
385 |
386 |
386 if match_tag: |
387 if match_tag: |
387 contenus[ts.datasheet_id]['score'] += 2*max_tag_order - ts.order |
388 contenus[ts.datasheet_id]['score'] += 2*max_tag_order - ts.order |
388 |
389 |
389 if contentlist is None: |
390 if contentlist is None: |
411 tags = [{'id': tag.id, |
412 tags = [{'id': tag.id, |
412 'label': tag.label, |
413 'label': tag.label, |
413 'score': tag.nb, |
414 'score': tag.nb, |
414 'thumbnail': dbpediafields[tag.id].thumbnail if tag.id in dbpediafields else None, |
415 'thumbnail': dbpediafields[tag.id].thumbnail if tag.id in dbpediafields else None, |
415 'translated_label': translations.get(dbpediafields[tag.id].id, tag.label) if tag.id in dbpediafields else tag.label, |
416 'translated_label': translations.get(dbpediafields[tag.id].id, tag.label) if tag.id in dbpediafields else tag.label, |
416 'url': tag.dbpedia_uri} for tag in tagqslist] |
417 'url': tag.dbpedia_uri, |
|
418 'wkpd_url': tag.wikipedia_url} for tag in tagqslist] |
417 |
419 |
418 countryqs = countryqs.annotate(nb=Count('includes__tag__taggedsheet')) |
420 countryqs = countryqs.annotate(nb=Count('includes__tag__taggedsheet')) |
419 countries = dict([(country.dbpedia_uri, country.nb) for country in countryqs]) |
421 countries = dict([(country.dbpedia_uri, country.nb) for country in countryqs]) |
420 |
422 |
421 discqslist = list(discqs.annotate(nb=Count('taggedsheet')).order_by('-nb')[:10]) |
423 discqslist = list(discqs.annotate(nb=Count('taggedsheet')).order_by('-nb')[:10]) |