Skip to content

Commit b15d7c4

Browse files
authored
Merge pull request #14 from MrIbrahem/update
Update
2 parents eab95b4 + cb2f48c commit b15d7c4

File tree

24 files changed

+272
-88
lines changed

24 files changed

+272
-88
lines changed

public_html/css/style2.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,10 @@ a {
7676
}
7777

7878
}
79+
80+
.navbar-nav .nav-item.active {
81+
/* border-radius: 4px; */
82+
/* display: block; */
83+
background-color: #c2c5c8;
84+
/* font-weight: bold; */
85+
}

public_html/duplicate_lemmas.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<div class="container-fluid">
88
<div class="row justify-content-center">
9-
<div class="col-8">
9+
<div class="col-lg-10 col-sm-12">
1010
<div class="card shadow rounded-4">
1111
<div class="card-header">
1212
<span id="h1" class="card-title fs-3 fw-bold mb-3"> المفردات المكررة </span>

public_html/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<div class="container-fluid">
88
<div class="row justify-content-center">
9-
<div class="col-8">
9+
<div class="col-lg-8 col-sm-12">
1010
<div class="card card_form">
1111
<div class="card-header text-center py-2">
1212
<h4 class="card-title mb-0 d-flex align-items-center justify-content-center">

public_html/js/lex/find_labels.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
async function find_labels() {
22
const spans = document.querySelectorAll("span[find-label]");
3-
3+
console.log(`find_labels: ${spans.length}`)
44
spans.forEach(async (span) => {
55
const qid = span.getAttribute("find-label");
6+
const both = span.getAttribute("find-label-both");
67
if (!qid) return;
78

89
// حاول الحصول على الاسم من localStorage أولاً
9-
const cached = localStorage.getItem(`wikidata-label-${qid}`);
10+
const cached = localStorage.getItem(`wikidata-label-2-${qid}`);
1011
if (cached) {
1112
span.textContent = cached;
1213
return;
@@ -28,9 +29,11 @@ async function find_labels() {
2829
}
2930

3031
if (labelAr) {
31-
span.textContent = labelAr;
32+
let labelAr2 = (both) ? `${labelAr} (${qid})` : labelAr;
33+
34+
span.textContent = labelAr2;
3235
// خزن الاسم في localStorage
33-
localStorage.setItem(`wikidata-label-${qid}`, labelAr);
36+
localStorage.setItem(`wikidata-label-2-${qid}`, labelAr2);
3437
}
3538
} catch (error) {
3639
console.error(`خطأ في جلب الاسم لـ ${qid}:`, error);

public_html/js/lex/lex_page_claims.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ let Labels = {
33
"P5186": "التصريف",
44
"P31": "فئة",
55
"P5920": "الجذر",
6+
"P5185": "الجنس النحوي",
67
"P11038": "الأنطولوجيا",
78
"P12900": "ARABTERM",
89
"P12901": "الهوراماني",
@@ -11,6 +12,7 @@ let Labels = {
1112
let only_show = [
1213
"P11038",
1314
"P5920",
15+
"P5185",
1416
]
1517

1618
let properties_formts = {

public_html/js/lexemes/list_lexemes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ function get_param_from_window_location(key, defaultvalue) {
144144
return urlParams.get(key) || defaultvalue;
145145
}
146146

147-
async function fetchData(limit, data_source, sort_by) {
147+
async function fetchListData(limit, data_source, sort_by) {
148148
// ---
149149
let treeMap = await make_wd_result(limit, data_source, sort_by);
150150

public_html/js/lexemes/wd.js

Lines changed: 62 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,65 @@ const noResultsDiv = document.getElementById("noResults");
88

99
let treeDataWD = [];
1010

11-
async function find_wd_result(to_group_by = "categoryLabel", limit = 100) {
11+
async function most_used_properties(data_source) {
12+
let VALUES = ``;
13+
// ---
14+
// if data_source match Q\d+
15+
if (data_source !== "" && data_source.match(/Q\d+/)) {
16+
VALUES = `VALUES ?category { wd:${data_source} }`;
17+
}
18+
// ---
19+
let query = `
20+
SELECT ?prop ?propLabel (COUNT(?item) AS ?usage)
21+
WHERE {
22+
${VALUES}
23+
?item rdf:type ontolex:LexicalEntry;
24+
wikibase:lemma ?lemma1;
25+
wikibase:lexicalCategory ?category; # الفئة: فعل
26+
dct:language wd:Q13955. # اللغة: العربية
27+
28+
# اختيار خصائص من مساحة بيانات Wikidata فقط
29+
?item ?wdtProp ?value.
30+
FILTER(STRSTARTS(STR(?wdtProp), STR(wdt:)))
31+
32+
# تحويل URI للخاصية إلى عنصر الـProperty نفسه (Pxxxx)
33+
BIND(IRI(REPLACE(STR(?wdtProp), STR(wdt:), STR(wd:))) AS ?prop)
34+
35+
SERVICE wikibase:label { bd:serviceParam wikibase:language "ar,en". }
36+
}
37+
GROUP BY ?prop ?propLabel
38+
ORDER BY DESC(?usage)
39+
`;
40+
// ---
41+
let result = await loadsparqlQuery(query);
42+
// ---
43+
return result;
44+
}
45+
46+
async function find_wd_result(to_group_by = "categoryLabel", data_source = "all", limit = 100) {
1247
// ---
1348
let props_in = [
1449
"P31",
15-
"P6771",
16-
"P11038",
17-
"P11757",
18-
"P12451"
1950
]
2051
// ---
2152
let add_group = "";
2253
let add_group_optional = "";
2354
// ---
2455
if (to_group_by.startsWith("P") && !props_in.includes(to_group_by) && to_group_by.match(/^P[0-9]+$/)) {
25-
to_group_by = to_group_by.replace("P", "");
26-
// if to_group_by is number
56+
// TODO: this has no sense
57+
// to_group_by = to_group_by.replace("P", "");
2758
add_group = `(GROUP_CONCAT(DISTINCT ?${to_group_by}_z; separator=", ") AS ?${to_group_by})`;
2859
add_group_optional = `OPTIONAL { ?item wdt:${to_group_by} ?${to_group_by}_z. }`;
2960

3061
}
3162
// ---
63+
let VALUES = ``;
64+
// ---
65+
// if data_source match Q\d+
66+
if (data_source !== "" && data_source.match(/Q\d+/)) {
67+
VALUES = `VALUES ?category { wd:${data_source} }`;
68+
}
69+
// ---
3270
const sparqlQuery = `
3371
SELECT
3472
?item
@@ -37,10 +75,10 @@ async function find_wd_result(to_group_by = "categoryLabel", limit = 100) {
3775
?category ?categoryLabel ?P31Label
3876
(GROUP_CONCAT(DISTINCT ?P6771_z; separator=", ") AS ?P6771)
3977
(GROUP_CONCAT(DISTINCT ?P11038_z; separator=", ") AS ?P11038)
40-
(GROUP_CONCAT(DISTINCT ?P11757_z; separator=", ") AS ?P11757)
4178
(GROUP_CONCAT(DISTINCT ?P12451_z; separator=", ") AS ?P12451)
4279
${add_group}
4380
WHERE {
81+
${VALUES}
4482
?item rdf:type ontolex:LexicalEntry;
4583
wikibase:lemma ?lemma1;
4684
wikibase:lexicalCategory ?category;
@@ -49,7 +87,6 @@ async function find_wd_result(to_group_by = "categoryLabel", limit = 100) {
4987
OPTIONAL { ?item wdt:P31 ?P31. }
5088
OPTIONAL { ?item wdt:P6771 ?P6771_z. }
5189
OPTIONAL { ?item wdt:P11038 ?P11038_z. }
52-
OPTIONAL { ?item wdt:P11757 ?P11757_z. }
5390
OPTIONAL { ?item wdt:P12451 ?P12451_z. }
5491
${add_group_optional}
5592
}
@@ -62,7 +99,7 @@ async function find_wd_result(to_group_by = "categoryLabel", limit = 100) {
6299
let wd_result = {};
63100

64101
for (const item of result) {
65-
let to_group = item[to_group_by] || '!';
102+
let to_group = item[to_group_by] || 'غير محدد';
66103

67104
if (!wd_result[to_group]) {
68105
// ---
@@ -119,11 +156,21 @@ function renderTree(data, all_open) {
119156
const isOpen = !ul.classList.contains("d-none");
120157
icon.className = `bi ${isOpen ? "bi-chevron-double-down" : "bi-chevron-double-left"} arrow-icon`;
121158
};
122-
159+
// ---
160+
let label = category.group_by;
161+
// ---
162+
if (label !== "" && (label.match(/Q\d+/) || label.match(/L\d+/))) {
163+
label = `<span find-label="${label}" find-label-both="true">${label}</span>`;
164+
}
165+
// ---
123166
// محتوى الزر عند الإنشاء
124167
button.innerHTML = `
125-
<span class="fw-medium text-black">${category.group_by}</span>
126-
<span class="text-muted ms-2">(${category.items.length})</span>
168+
<span class="fw-medium text-black">
169+
${label}
170+
</span>
171+
<span class="text-muted ms-2">
172+
(${category.items.length})
173+
</span>
127174
<i class="bi bi-chevron-double-left arrow-icon"></i>
128175
`;
129176

@@ -174,9 +221,9 @@ function get_param_from_window_location1(key, defaultvalue) {
174221
return urlParams.get(key) || defaultvalue;
175222
}
176223

177-
async function fetchData(limit, group_by) {
224+
async function fetchData(limit, data_source, group_by) {
178225
// ---
179-
const treeMap = await find_wd_result(group_by, limit);
226+
const treeMap = await find_wd_result(group_by, data_source, limit);
180227

181228
// count all items.length in wd_result
182229
let count = Object.values(treeMap).reduce((sum, obj) => sum + obj.items.length, 0);

public_html/js/lexemes/wd_result.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ function parse_results(result) {
6161
}
6262

6363
async function load_wd(limit, data_source, sort_by) {
64-
let VALUES = ``;
6564
const sparqlQuery1 = `
6665
VALUES ?category {
6766
wd:Q111029 # جذر
@@ -71,6 +70,8 @@ async function load_wd(limit, data_source, sort_by) {
7170
}
7271
`;
7372
// ---
73+
let VALUES = ``;
74+
// ---
7475
// if data_source match Q\d+
7576
if (data_source !== "" && data_source.match(/Q\d+/)) {
7677
VALUES = `VALUES ?category { wd:${data_source} }`;

public_html/list.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function loadfetchData() {
8181
document.getElementById('custom_data_source').style.display = 'block';
8282
}
8383
// ---
84-
fetchData(limit, data_source);
84+
fetchListData(limit, data_source);
8585
}
8686

8787
function toggleCustomInput() {

public_html/main.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,23 @@
5858
<span class="navbar-toggler-icon"></span>
5959
</button>
6060
<div class="collapse navbar-collapse" id="collapsibleNavbar">
61-
<ul class="navbar-nav flex-row flex-wrap bd-navbar-nav">
62-
<li class="nav-item col-6 col-lg-auto">
61+
<ul class="navbar-nav flex-row flex-wrap bd-navbar-nav navbar-default">
62+
<li class="nav-item col-6 col-lg-auto <?= basename($_SERVER['REQUEST_URI']) == 'list.php' ? 'active' : '' ?> ">
6363
<a class="nav-link" href="/list.php"><i class="bi bi-journal-text ms-1"></i>
6464
قائمة المفردات
6565
</a>
6666
</li>
67-
<li class="nav-item col-6 col-lg-auto">
67+
<li class="nav-item col-6 col-lg-auto <?= basename($_SERVER['REQUEST_URI']) == 'new.php' ? 'active' : '' ?> ">
6868
<a class="nav-link" href="/new.php"><i class="bi bi-journal-text ms-1"></i>
6969
أحدث المفردات
7070
</a>
7171
</li>
72-
<li class="nav-item col-6 col-lg-auto">
72+
<li class="nav-item col-6 col-lg-auto <?= basename($_SERVER['REQUEST_URI']) == 'duplicate_lemmas.php' ? 'active' : '' ?> ">
7373
<a class="nav-link" href="/duplicate_lemmas.php"><i class="bi bi-journal-text ms-1"></i>
7474
المكررات
7575
</a>
7676
</li>
77-
<li class="nav-item col-6 col-lg-auto">
77+
<li class="nav-item col-6 col-lg-auto <?= basename($_SERVER['REQUEST_URI']) == 'wd.php' ? 'active' : '' ?> ">
7878
<a class="nav-link" href="/wd.php"><i class="bi bi-tree ms-1"></i>
7979
مخطط شجري
8080
</a>

0 commit comments

Comments
 (0)