Update nat_datasets.py
Browse files- nat_datasets.py +26 -23
nat_datasets.py
CHANGED
@@ -48,27 +48,27 @@ match1_done = 0
|
|
48 |
|
49 |
|
50 |
def new_func(value, ar_tab):
|
51 |
-
#
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
return "", ""
|
73 |
|
74 |
|
@@ -103,8 +103,11 @@ for tab in tqdm.tqdm(data):
|
|
103 |
if not NAT_PATTERN:
|
104 |
continue
|
105 |
# ---
|
106 |
-
key1 = re.sub(rf'\b{re.escape(en_country)}\b', EN_NAT_PATTERN, key, re.IGNORECASE)
|
107 |
-
|
|
|
|
|
|
|
108 |
# ---
|
109 |
# if EN_NAT_PATTERN in key1 and NAT_PATTERN in value1:
|
110 |
# ---
|
|
|
48 |
|
49 |
|
50 |
def new_func(value, ar_tab):
|
51 |
+
# List of possible keys and their corresponding tags
|
52 |
+
patterns = [
|
53 |
+
("men", "{NAT_MEN}"),
|
54 |
+
("womens", "{NAT_WOMENS}"),
|
55 |
+
("women", "{NAT_WOMEN}"),
|
56 |
+
("man", "{NAT_MAN}"),
|
57 |
+
]
|
58 |
+
|
59 |
+
# Iterate through the patterns
|
60 |
+
for key, tag in patterns:
|
61 |
+
country = ar_tab.get(key, "")
|
62 |
+
if not country:
|
63 |
+
continue
|
64 |
+
# ---
|
65 |
+
country2 = f"ال{country}".replace(" ", " ال")
|
66 |
+
# ---
|
67 |
+
if country2 in value:
|
68 |
+
return country2, tag
|
69 |
+
elif country in value:
|
70 |
+
return country, tag
|
71 |
+
|
72 |
return "", ""
|
73 |
|
74 |
|
|
|
103 |
if not NAT_PATTERN:
|
104 |
continue
|
105 |
# ---
|
106 |
+
key1 = re.sub(rf'\b{re.escape(en_country)}\b', EN_NAT_PATTERN, f" {key} ", re.IGNORECASE)
|
107 |
+
key1 = key1.strip()
|
108 |
+
# ---
|
109 |
+
value1 = re.sub(rf'\b{re.escape(ar_country)}\b', NAT_PATTERN, f" {value} ", re.IGNORECASE)
|
110 |
+
value1 = value1.strip()
|
111 |
# ---
|
112 |
# if EN_NAT_PATTERN in key1 and NAT_PATTERN in value1:
|
113 |
# ---
|