Exemplo n.º 1
0
 def calculate_total_lexemes(self):
     """Calculate how many lexemes exists in Wikidata"""
     result = (execute_sparql_query(f'''
     SELECT
     (COUNT(?l) as ?count)
     WHERE {{
       ?l a ontolex:LexicalEntry.
     }}'''))
     count: int = wdqs.extract_count(result)
     logging.debug(f"count:{count}")
     self.total_lexemes = count
Exemplo n.º 2
0
 def count_number_of_lexemes(self):
     """Returns an int"""
     logger = logging.getLogger(__name__)
     result = (execute_sparql_query(f'''
     SELECT
     (COUNT(?l) as ?count)
     WHERE {{
       ?l dct:language wd:{self.language_qid.value}.
     }}'''))
     logger.debug(f"result:{result}")
     count: int = wdqs.extract_count(result)
     logging.debug(f"count:{count}")
     return count
Exemplo n.º 3
0
 def count_number_of_senses_with_P5137(self):
     """Returns an int"""
     result = (execute_sparql_query(f'''
     SELECT
     (COUNT(?sense) as ?count)
     WHERE {{
       VALUES ?l {{wd:{self.id}}}.
       ?l ontolex:sense ?sense.
       ?sense skos:definition ?gloss.
       # Exclude lexemes without a linked QID from at least one sense
       ?sense wdt:P5137 [].
     }}'''))
     count: int = wdqs.extract_count(result)
     logging.debug(f"count:{count}")
     return count
Exemplo n.º 4
0
 def count_number_of_senses_with_p5137(self):
     """Returns an int"""
     logger = logging.getLogger(__name__)
     result = (execute_sparql_query(f'''
     SELECT
     (COUNT(?sense) as ?count)
     WHERE {{
       ?l dct:language wd:{self.language_qid.value}.
       ?l ontolex:sense ?sense.
       ?sense skos:definition ?gloss.
       # Exclude lexemes without a linked QID from at least one sense
       ?sense wdt:P5137 [].
     }}'''))
     logger.debug(f"result:{result}")
     count: int = wdqs.extract_count(result)
     logging.debug(f"count:{count}")
     return count
Exemplo n.º 5
0
 def count_number_of_forms_without_an_example(self):
     """Returns an int"""
     # TODO fix this to count all senses in a given language
     result = (execute_sparql_query(f'''
     SELECT
     (COUNT(?form) as ?count)
     WHERE {{
       ?l dct:language wd:{self.language_qid.value}.
       ?l ontolex:lexicalForm ?form.
       ?l ontolex:sense ?sense.
       # exclude lexemes that already have at least one example
       MINUS {{?l wdt:P5831 ?example.}}
       # Exclude lexemes without a linked QID from at least one sense
       ?sense wdt:P5137 [].
     }}'''))
     count: int = wdqs.extract_count(result)
     logging.debug(f"count:{count}")
     self.number_of_forms_without_an_example = count