def setup_top_concepts(rdf, mark_top_concepts):
for cs in sorted(rdf.subjects(RDF.type, SKOS.ConceptScheme)):<EOL><INDENT>for conc in sorted(rdf.subjects(SKOS.inScheme, cs)):<EOL><INDENT>if (conc, RDF.type, SKOS.Concept) not in rdf:<EOL><INDENT>continue  <EOL><DEDENT>broader = rdf.value(conc, SKOS.broader, None, any=True)<EOL>if broader is None:  <EOL><INDENT>if (cs, SKOS.hasTopConcept, conc) not in rdf and(conc, SKOS.topConceptOf, cs) not in rdf:<EOL><INDENT>if mark_top_concepts:<EOL><INDENT>logging.info(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>", conc, cs)<EOL>rdf.add((cs, SKOS.hasTopConcept, conc))<EOL>rdf.add((conc, SKOS.topConceptOf, cs))<EOL><DEDENT>else:<EOL><INDENT>logging.debug(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>conc, cs)<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>
Determine the top concepts of each concept scheme and mark them using
    hasTopConcept/topConceptOf.