fuzzy-dl-owl2 1.0.8__py3-none-any.whl → 1.0.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,9 +4,11 @@ import typing
4
4
  from rdflib import Namespace
5
5
 
6
6
  from fuzzy_dl_owl2.fuzzydl.util import constants
7
+ from fuzzy_dl_owl2.fuzzydl.util.config_reader import ConfigReader
7
8
  from fuzzy_dl_owl2.fuzzydl.util.util import Util
8
9
  from fuzzy_dl_owl2.fuzzyowl2.owl_types.choquet_concept import ChoquetConcept
9
10
  from fuzzy_dl_owl2.fuzzyowl2.owl_types.concept_definition import ConceptDefinition
11
+ from fuzzy_dl_owl2.fuzzyowl2.owl_types.crisp_function import CrispFunction
10
12
  from fuzzy_dl_owl2.fuzzyowl2.owl_types.fuzzy_datatype import FuzzyDatatype
11
13
  from fuzzy_dl_owl2.fuzzyowl2.owl_types.fuzzy_modifier import FuzzyModifier
12
14
  from fuzzy_dl_owl2.fuzzyowl2.owl_types.fuzzy_nominal_concept import FuzzyNominalConcept
@@ -146,8 +148,6 @@ from pyowl2.individual.anonymous_individual import OWLAnonymousIndividual
146
148
  from pyowl2.literal.literal import OWLLiteral
147
149
  from pyowl2.ontology import OWLOntology
148
150
 
149
- from fuzzy_dl_owl2.fuzzydl.util.config_reader import ConfigReader
150
-
151
151
 
152
152
  class FuzzyOwl2(object):
153
153
  POS_INFINITY: float = 10000.0
@@ -219,12 +219,16 @@ class FuzzyOwl2(object):
219
219
  if datatype_def_axioms is None:
220
220
  continue
221
221
  for axiom in datatype_def_axioms:
222
+ Util.debug(f"Getting facets for axiom {axiom}...")
222
223
  assert isinstance(axiom, OWLDatatypeDefinition)
223
224
  datatype_name: str = self.get_short_name(axiom.datatype).replace(
224
225
  ":", ""
225
226
  )
226
227
  if datatype_name != name:
227
228
  continue
229
+ f1: typing.Optional[OWLFacet] = None
230
+ f2: typing.Optional[OWLFacet] = None
231
+ Util.debug(f"Getting facets for data range {axiom.data_range}...")
228
232
  if isinstance(axiom.data_range, OWLDatatypeRestriction):
229
233
  facets: list[OWLFacet] = list(axiom.data_range.restrictions)
230
234
  f1: OWLFacet = facets[0]
@@ -260,14 +264,27 @@ class FuzzyOwl2(object):
260
264
  continue
261
265
  f1: OWLFacet = facets1[0]
262
266
  f2: OWLFacet = facets2[0]
263
- if f1.constraint_to_uriref() == OWLFacet.MIN_INCLUSIVE:
264
- facets[0] = float(str(f1.value.value))
265
- elif f1.constraint_to_uriref() == OWLFacet.MAX_INCLUSIVE:
266
- facets[1] = float(str(f1.value.value))
267
- if f2.constraint_to_uriref() == OWLFacet.MIN_INCLUSIVE:
268
- facets[0] = float(str(f2.value.value))
269
- elif f2.constraint_to_uriref() == OWLFacet.MAX_INCLUSIVE:
270
- facets[1] = float(str(f2.value.value))
267
+
268
+ Util.debug(f"Facets 1 {f1}.")
269
+ Util.debug(f"Facets 2 {f2}.")
270
+ if f1:
271
+ if f1.constraint_to_uriref() == OWLFacet.MIN_INCLUSIVE:
272
+ facets[0] = float(str(f1.value.value))
273
+ elif f1.constraint_to_uriref() == OWLFacet.MIN_EXCLUSIVE:
274
+ facets[0] = float(str(f1.value.value)) + ConfigReader.EPSILON
275
+ elif f1.constraint_to_uriref() == OWLFacet.MAX_INCLUSIVE:
276
+ facets[1] = float(str(f1.value.value))
277
+ elif f1.constraint_to_uriref() == OWLFacet.MAX_EXCLUSIVE:
278
+ facets[1] = float(str(f1.value.value)) - ConfigReader.EPSILON
279
+ if f2:
280
+ if f2.constraint_to_uriref() == OWLFacet.MIN_INCLUSIVE:
281
+ facets[0] = float(str(f2.value.value))
282
+ elif f2.constraint_to_uriref() == OWLFacet.MIN_EXCLUSIVE:
283
+ facets[0] = float(str(f2.value.value)) + ConfigReader.EPSILON
284
+ elif f2.constraint_to_uriref() == OWLFacet.MAX_INCLUSIVE:
285
+ facets[1] = float(str(f2.value.value))
286
+ elif f2.constraint_to_uriref() == OWLFacet.MAX_INCLUSIVE:
287
+ facets[1] = float(str(f2.value.value)) - ConfigReader.EPSILON
271
288
  return facets
272
289
  return facets
273
290
 
@@ -301,7 +318,9 @@ class FuzzyOwl2(object):
301
318
  c.set_max_value(facets[1])
302
319
  Util.debug(f"Concept for {datatype} -> {c}")
303
320
  self.fuzzy_datatypes[datatype_name] = c
304
- if isinstance(c, LeftShoulderFunction):
321
+ if isinstance(c, CrispFunction):
322
+ self.write_crisp_function_definition(datatype_name, c)
323
+ elif isinstance(c, LeftShoulderFunction):
305
324
  self.write_left_shoulder_function_definition(datatype_name, c)
306
325
  elif isinstance(c, RightShoulderFunction):
307
326
  self.write_right_shoulder_function_definition(datatype_name, c)
@@ -913,6 +932,7 @@ class FuzzyOwl2(object):
913
932
  )
914
933
 
915
934
  def get_class_name(self, c: OWLClassExpression) -> str:
935
+ Util.debug(f"Getting class name for expression: {c}")
916
936
  if isinstance(c, OWLClass):
917
937
  d: OWLClass = typing.cast(OWLClass, c)
918
938
  if d.is_thing():
@@ -1053,6 +1073,7 @@ class FuzzyOwl2(object):
1053
1073
  raise ValueError
1054
1074
 
1055
1075
  def get_object_property_name(self, p: OWLObjectPropertyExpression) -> str:
1076
+ Util.debug(f"Getting object property name for expression: {p}")
1056
1077
  if p.is_top_object_property():
1057
1078
  return self.get_top_object_property_name()
1058
1079
  elif p.is_bottom_object_property():
@@ -1061,6 +1082,7 @@ class FuzzyOwl2(object):
1061
1082
  return self.get_atomic_object_property_name(p)
1062
1083
 
1063
1084
  def get_data_property_name(self, p: OWLDataPropertyExpression) -> str:
1085
+ Util.debug(f"Getting data property name for expression: {p}")
1064
1086
  if p.is_top_data_property():
1065
1087
  return self.get_top_data_property_name()
1066
1088
  elif p.is_bottom_data_property():
@@ -1069,6 +1091,7 @@ class FuzzyOwl2(object):
1069
1091
  return self.get_atomic_data_property_name(p)
1070
1092
 
1071
1093
  def get_individual_name(self, i: OWLIndividual) -> typing.Optional[str]:
1094
+ Util.debug(f"Getting individual name for expression: {i}")
1072
1095
  if isinstance(i, OWLAnonymousIndividual):
1073
1096
  Util.info(f"Anonymous individual not supported")
1074
1097
  return None
@@ -1221,7 +1244,7 @@ class FuzzyOwl2(object):
1221
1244
 
1222
1245
  def get_atomic_object_property_name(self, p: OWLObjectProperty) -> str:
1223
1246
  name: str = self.get_short_name(p)
1224
- Util.info(f"Write object property {name}")
1247
+ Util.info(f"Write atomic object property {name}")
1225
1248
  return ""
1226
1249
 
1227
1250
  def get_top_data_property_name(self) -> str:
@@ -1234,27 +1257,27 @@ class FuzzyOwl2(object):
1234
1257
 
1235
1258
  def get_atomic_data_property_name(self, p: OWLDataProperty) -> str:
1236
1259
  name: str = self.get_short_name(p)
1237
- Util.info(f"Write data property {name}")
1260
+ Util.info(f"Write atomic data property {name}")
1238
1261
  return ""
1239
1262
 
1240
1263
  def write_fuzzy_logic(self, logic: str) -> None:
1241
1264
  Util.info(f"Write fuzzy logic {logic}")
1242
1265
 
1243
1266
  def write_concept_declaration(self, c: OWLClassExpression) -> None:
1244
- Util.info(f"Write declaration {c}")
1267
+ Util.info(f"Write concept declaration {c}")
1245
1268
 
1246
1269
  def write_data_property_declaration(self, dp: OWLDataPropertyExpression) -> None:
1247
- Util.info(f"Write declaration {dp}")
1270
+ Util.info(f"Write data property declaration {dp}")
1248
1271
 
1249
1272
  def write_object_property_declaration(
1250
1273
  self, op: OWLObjectPropertyExpression
1251
1274
  ) -> None:
1252
- Util.info(f"Write declaration {op}")
1275
+ Util.info(f"Write object property declaration {op}")
1253
1276
 
1254
1277
  def write_concept_assertion_axiom(
1255
1278
  self, i: OWLIndividual, c: OWLClassExpression, d: float
1256
1279
  ) -> None:
1257
- Util.info(f"Write axiom {i}: {c} >= {d}")
1280
+ Util.info(f"Write concept assertion axiom {i}: {c} >= {d}")
1258
1281
 
1259
1282
  def write_object_property_assertion_axiom(
1260
1283
  self,
@@ -1263,7 +1286,7 @@ class FuzzyOwl2(object):
1263
1286
  p: OWLObjectPropertyExpression,
1264
1287
  d: float,
1265
1288
  ) -> None:
1266
- Util.info(f"Write axiom ({i1}, {i2}): {p} >= {d}")
1289
+ Util.info(f"Write object property assertion axiom ({i1}, {i2}): {p} >= {d}")
1267
1290
 
1268
1291
  def write_data_property_assertion_axiom(
1269
1292
  self,
@@ -1272,7 +1295,7 @@ class FuzzyOwl2(object):
1272
1295
  p: OWLDataPropertyExpression,
1273
1296
  d: float,
1274
1297
  ) -> None:
1275
- Util.info(f"Write axiom ({i}, {lit}): {p} >= {d}")
1298
+ Util.info(f"Write data property assertion axiom ({i}, {lit}): {p} >= {d}")
1276
1299
 
1277
1300
  def write_negative_object_property_assertion_axiom(
1278
1301
  self,
@@ -1281,7 +1304,9 @@ class FuzzyOwl2(object):
1281
1304
  p: OWLObjectPropertyExpression,
1282
1305
  d: float,
1283
1306
  ) -> None:
1284
- Util.info(f"Write axiom ({i1}, {i2}): not {p} >= {d}")
1307
+ Util.info(
1308
+ f"Write negative object property assertion axiom ({i1}, {i2}): not {p} >= {d}"
1309
+ )
1285
1310
 
1286
1311
  def write_negative_data_property_assertion_axiom(
1287
1312
  self,
@@ -1290,7 +1315,9 @@ class FuzzyOwl2(object):
1290
1315
  p: OWLDataPropertyExpression,
1291
1316
  d: float,
1292
1317
  ) -> None:
1293
- Util.info(f"Write axiom ({i}, {lit}): not {p} >= {d}")
1318
+ Util.info(
1319
+ f"Write negative data property assertion axiom ({i}, {lit}): not {p} >= {d}"
1320
+ )
1294
1321
 
1295
1322
  def write_same_individual_axiom(self, ind_set: set[OWLIndividual]) -> None:
1296
1323
  Util.info(f"Write axiom SameIndividual({ind_set})")
@@ -1394,7 +1421,7 @@ class FuzzyOwl2(object):
1394
1421
  def write_inverse_object_property_axiom(
1395
1422
  self, p1: OWLObjectPropertyExpression, p2: OWLObjectPropertyExpression
1396
1423
  ) -> None:
1397
- Util.info(f"Write axiom ({p1} inverse of {p2})")
1424
+ Util.info(f"Write inverse object property axiom - axiom ({p1} inverse of {p2})")
1398
1425
 
1399
1426
  def write_inverse_functional_object_property_axiom(
1400
1427
  self, p: OWLObjectPropertyExpression
@@ -1424,100 +1451,103 @@ class FuzzyOwl2(object):
1424
1451
  def write_disjoint_object_properties_axiom(
1425
1452
  self, class_set: set[OWLObjectPropertyExpression]
1426
1453
  ) -> None:
1427
- Util.info(f"Write axiom ({class_set})")
1454
+ Util.info(f"Write disjoint object properties axiom ({class_set})")
1428
1455
 
1429
1456
  def write_disjoint_data_properties_axiom(
1430
1457
  self, class_set: set[OWLDataPropertyExpression]
1431
1458
  ) -> None:
1432
- Util.info(f"Write axiom ({class_set})")
1459
+ Util.info(f"Write disjoint data properties axiom ({class_set})")
1433
1460
 
1434
1461
  def write_triangular_modifier_definition(
1435
1462
  self, name: str, mod: TriangularModifier
1436
1463
  ) -> None:
1437
- Util.info(f"Write definition {name} = {mod}")
1464
+ Util.info(f"Write triangular modifier definition {name} = {mod}")
1438
1465
 
1439
1466
  def write_linear_modifier_definition(self, name: str, mod: LinearModifier) -> None:
1440
- Util.info(f"Write definition {name} = {mod}")
1467
+ Util.info(f"Write linear modifier definition {name} = {mod}")
1468
+
1469
+ def write_crisp_function_definition(self, name: str, dat: CrispFunction) -> None:
1470
+ Util.info(f"Write crisp function definition {name} = {dat}")
1441
1471
 
1442
1472
  def write_left_shoulder_function_definition(
1443
1473
  self, name: str, dat: LeftShoulderFunction
1444
1474
  ) -> None:
1445
- Util.info(f"Write definition {name} = {dat}")
1475
+ Util.info(f"Write left shoulder function definition {name} = {dat}")
1446
1476
 
1447
1477
  def write_right_shoulder_function_definition(
1448
1478
  self, name: str, dat: RightShoulderFunction
1449
1479
  ) -> None:
1450
- Util.info(f"Write definition {name} = {dat}")
1480
+ Util.info(f"Write right shoulder function definition {name} = {dat}")
1451
1481
 
1452
1482
  def write_linear_function_definition(self, name: str, dat: LinearFunction) -> None:
1453
- Util.info(f"Write definition {name} = {dat}")
1483
+ Util.info(f"Write linear function definition {name} = {dat}")
1454
1484
 
1455
1485
  def write_triangular_function_definition(
1456
1486
  self, name: str, dat: TriangularFunction
1457
1487
  ) -> None:
1458
- Util.info(f"Write definition {name} = {dat}")
1488
+ Util.info(f"Write triangular function definition {name} = {dat}")
1459
1489
 
1460
1490
  def write_trapezoidal_function_definition(
1461
1491
  self, name: str, dat: TrapezoidalFunction
1462
1492
  ) -> None:
1463
- Util.info(f"Write definition {name} = {dat}")
1493
+ Util.info(f"Write trapezoidal function definition {name} = {dat}")
1464
1494
 
1465
1495
  def write_modified_function_definition(
1466
1496
  self, name: str, dat: ModifiedFunction
1467
1497
  ) -> None:
1468
- Util.info(f"Write definition {name} = {dat}")
1498
+ Util.info(f"Write modified function definition {name} = {dat}")
1469
1499
 
1470
1500
  def write_modified_property_definition(
1471
1501
  self, name: str, dat: ModifiedProperty
1472
1502
  ) -> None:
1473
- Util.info(f"Write definition {name} = {dat}")
1503
+ Util.info(f"Write modified property definition {name} = {dat}")
1474
1504
 
1475
1505
  def write_modified_concept_definition(
1476
1506
  self, name: str, dat: ModifiedConcept
1477
1507
  ) -> None:
1478
- Util.info(f"Write definition {name} = {dat}")
1508
+ Util.info(f"Write modified concept definition {name} = {dat}")
1479
1509
 
1480
1510
  def write_fuzzy_nominal_concept_definition(
1481
1511
  self, name: str, dat: FuzzyNominalConcept
1482
1512
  ) -> None:
1483
- Util.info(f"Write definition {name} = {dat}")
1513
+ Util.info(f"Write fuzzy nominal concept definition {name} = {dat}")
1484
1514
 
1485
1515
  def write_weighted_concept_definition(self, name: str, c: WeightedConcept) -> None:
1486
- Util.info(f"Write definition {name} = {c}")
1516
+ Util.info(f"Write weighted concept definition {name} = {c}")
1487
1517
 
1488
1518
  def write_weighted_max_concept_definition(
1489
1519
  self, name: str, c: WeightedMaxConcept
1490
1520
  ) -> None:
1491
- Util.info(f"Write definition {name} = {c}")
1521
+ Util.info(f"Write weighted max concept definition {name} = {c}")
1492
1522
 
1493
1523
  def write_weighted_min_concept_definition(
1494
1524
  self, name: str, c: WeightedMinConcept
1495
1525
  ) -> None:
1496
- Util.info(f"Write definition {name} = {c}")
1526
+ Util.info(f"Write weighted min concept definition {name} = {c}")
1497
1527
 
1498
1528
  def write_weighted_sum_concept_definition(
1499
1529
  self, name: str, c: WeightedSumConcept
1500
1530
  ) -> None:
1501
- Util.info(f"Write definition {name} = {c}")
1531
+ Util.info(f"Write weighted sum concept definition {name} = {c}")
1502
1532
 
1503
1533
  def write_weighted_sum_zero_concept_definition(
1504
1534
  self, name: str, c: WeightedSumZeroConcept
1505
1535
  ) -> None:
1506
- Util.info(f"Write definition {name} = {c}")
1536
+ Util.info(f"Write weighted sum zero concept definition {name} = {c}")
1507
1537
 
1508
1538
  def write_owa_concept_definition(self, name: str, c: OwaConcept) -> None:
1509
- Util.info(f"Write definition {name} = {c}")
1539
+ Util.info(f"Write owa concept definition {name} = {c}")
1510
1540
 
1511
1541
  def write_choquet_concept_definition(self, name: str, c: ChoquetConcept) -> None:
1512
- Util.info(f"Write definition {name} = {c}")
1542
+ Util.info(f"Write choquet concept definition {name} = {c}")
1513
1543
 
1514
1544
  def write_sugeno_concept_definition(self, name: str, c: SugenoConcept) -> None:
1515
- Util.info(f"Write definition {name} = {c}")
1545
+ Util.info(f"Write sugeno concept definition {name} = {c}")
1516
1546
 
1517
1547
  def write_quasi_sugeno_concept_definition(
1518
1548
  self, name: str, c: QsugenoConcept
1519
1549
  ) -> None:
1520
- Util.info(f"Write definition {name} = {c}")
1550
+ Util.info(f"Write quasi sugeno concept definition {name} = {c}")
1521
1551
 
1522
1552
  def write_qowa_concept_definition(self, name: str, c: QowaConcept) -> None:
1523
- Util.info(f"Write definition {name} = {c}")
1553
+ Util.info(f"Write quasi owa concept definition {name} = {c}")