Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
MrIbrahem committed Dec 17, 2024
1 parent 8a783dd commit 8b1604a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 10 deletions.
2 changes: 1 addition & 1 deletion nep/si3g.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def mainwithcat2():
printe.output("*<<lightred>> > mainwithcat2 :")
# ---
for num, q in enumerate(lista, start=1):
si3.ISRE(q, num, lena, get_nl_des=False)
si3.ISRE(q, num, lena)
# ---
si3.print_new_types()
# ---
Expand Down
50 changes: 41 additions & 9 deletions nep/si3g_qua.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,72 @@
python3 core8/pwb.py nep/si3g_qua
python3 core8/pwb.py nep/si3g_qua -p27:Q805
"""
import sys
from newapi import printe
from nep import si3
from wd_api import wd_bot
from people.people_get_topic import job_to_qid, nat_to_qid

qua = """
SELECT DISTINCT
?item
(concat(strafter(str(?item),"/entity/")) as ?qid)
WHERE {
?item wdt:P31 wd:Q5 .
?item wdt:P21 ?p211.
?item wdt:P27 ?p27.
?item wdt:P106 ?p106.
FILTER NOT EXISTS {?item schema:description ?en filter (lang(?en) = "en")} .
#sr
?item wdt:P31 wd:Q5 .
?item wdt:P21 ?p211.
?item wdt:P27 ?p27.
?item wdt:P106 ?p106.
FILTER NOT EXISTS {?item schema:description ?en filter (lang(?en) = "en")} .
}
LIMIT 100
"""
limit = {1: "100"}
P106 = {1: []}
P27 = {1: []}

for arg in sys.argv:
# ---
arg, _, value = arg.partition(":")
# ---
if arg.startswith("-"):
arg = arg[1:]
# ---
if arg == "limit":
limit[1] = value
# ---
if arg.lower() == "p106":
P106[1].append(value)
# ---
if arg.lower() == "p27":
P27[1].append(value)

qua += f"\n limit {limit[1]}"
# ---
if P106[1]:
line = "values ?p106 {" + " ".join([f"wd:{x}" for x in P106[1]]) + "} \n #sr"
qua = qua.replace("#sr", line, 1)
# ---
if P27[1]:
line = "values ?p27 {" + " ".join([f"wd:{x}" for x in P27[1]]) + "} \n #sr"
qua = qua.replace("#sr", line, 1)


def main():
printe.output("*<<lightred>> > main:")
# ---
lista = wd_bot.sparql_generator_url(qua)
# ---
printe.output("*<<lightred>> > mainwithcat2 :")
printe.output(f"*<<yellow>> {qua} :")
# ---
for num, tab in enumerate(lista, start=1):
qid = tab["qid"]
# {'item': 'http://www.wikidata.org/entity/Q21457154', 'qid': 'Q21457154'}
si3.ISRE(qid, num, len(lista))
si3.ISRE(qid, num, len(lista), get_nl_des=False)
# ---
si3.print_new_types()

Expand Down
1 change: 1 addition & 0 deletions people/people_get_topic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/python3
"""
from people.people_get_topic import job_to_qid, nat_to_qid
from people.people_get_topic import get_topic
python3 core8/pwb.py people/people_get_topic
Expand Down

0 comments on commit 8b1604a

Please sign in to comment.