Esempio n. 1
0
 def processOntologyItem(self, begin: 'Token') -> 'ReferentToken':
     if (not ((isinstance(begin, TextToken)))):
         return None
     ut = UnitToken.tryParse(begin, None, None, False)
     if (ut is not None):
         return ReferentToken(ut.createReferentWithRegister(None),
                              ut.begin_token, ut.end_token)
     u = UnitReferent()
     u.addSlot(UnitReferent.ATTR_NAME, begin.getSourceText(), False, 0)
     return ReferentToken(u, begin, begin)
Esempio n. 2
0
 def process_ontology_item(self, begin: 'Token') -> 'ReferentToken':
     if (not (isinstance(begin, TextToken))):
         return None
     ut = UnitToken.try_parse(begin, None, None, False)
     if (ut is not None):
         return ReferentToken(ut.create_referent_with_register(None),
                              ut.begin_token, ut.end_token)
     u = UnitReferent()
     u.add_slot(UnitReferent.ATTR_NAME, begin.get_source_text(), False, 0)
     return ReferentToken(u, begin, begin)
Esempio n. 3
0
 def __create_referent(u: 'Unit') -> 'UnitReferent':
     ur = UnitReferent()
     ur.add_slot(UnitReferent.ATTR_NAME, u.name_cyr, False, 0)
     ur.add_slot(UnitReferent.ATTR_NAME, u.name_lat, False, 0)
     ur.add_slot(UnitReferent.ATTR_FULLNAME, u.fullname_cyr, False, 0)
     ur.add_slot(UnitReferent.ATTR_FULLNAME, u.fullname_lat, False, 0)
     ur.tag = u
     ur._m_unit = u
     return ur
Esempio n. 4
0
 def create_referent_with_register(self,
                                   ad: 'AnalyzerData') -> 'UnitReferent':
     ur = self.ext_onto
     if (self.unit is not None):
         ur = UnitToken.__create_referent(self.unit)
     elif (self.unknown_name is not None):
         ur = UnitReferent()
         ur.add_slot(UnitReferent.ATTR_NAME, self.unknown_name, False, 0)
         ur.is_unknown = True
     if (self.pow0_ != 1):
         ur.add_slot(UnitReferent.ATTR_POW, str(self.pow0_), False, 0)
     owns = list()
     owns.append(ur)
     if (self.unit is not None):
         uu = self.unit.base_unit
         while uu is not None:
             ur0 = UnitToken.__create_referent(uu)
             owns.append(ur0)
             uu = uu.base_unit
     for i in range(len(owns) - 1, -1, -1):
         if (ad is not None):
             owns[i] = (Utils.asObjectOrNull(ad.register_referent(owns[i]),
                                             UnitReferent))
         if (i > 0):
             owns[i - 1].add_slot(UnitReferent.ATTR_BASEUNIT, owns[i],
                                  False, 0)
             if (owns[i - 1].tag.base_multiplier != 0):
                 owns[i - 1].add_slot(
                     UnitReferent.ATTR_BASEFACTOR,
                     NumberHelper.double_to_string(
                         owns[i - 1].tag.base_multiplier), False, 0)
     return owns[0]
Esempio n. 5
0
 def createReferent(self, type0_: str) -> 'Referent':
     if (type0_ == MeasureReferent.OBJ_TYPENAME):
         return MeasureReferent()
     if (type0_ == UnitReferent.OBJ_TYPENAME):
         return UnitReferent()
     return None