Пример #1
0
 def images(self) -> typing.List[tuple]:
     res = dict()
     res[Utils.enumToString(NamedEntityKind.MONUMENT)] = EpNerCoreInternalResourceHelper.getBytes("monument.png")
     res[Utils.enumToString(NamedEntityKind.PLANET)] = EpNerCoreInternalResourceHelper.getBytes("planet.png")
     res[Utils.enumToString(NamedEntityKind.LOCATION)] = EpNerCoreInternalResourceHelper.getBytes("location.png")
     res[Utils.enumToString(NamedEntityKind.BUILDING)] = EpNerCoreInternalResourceHelper.getBytes("building.png")
     return res
Пример #2
0
 def initialize() -> None:
     from pullenti.ner.date.DateReferent import DateReferent
     MetaDate.GLOBAL_META = MetaDate()
     MetaDate.GLOBAL_META.add_feature(DateReferent.ATTR_ISRELATIVE, "Относительность", 0, 1)
     MetaDate.GLOBAL_META.add_feature(DateReferent.ATTR_CENTURY, "Век", 0, 1)
     MetaDate.GLOBAL_META.add_feature(DateReferent.ATTR_YEAR, "Год", 0, 1)
     MetaDate.GLOBAL_META.add_feature(DateReferent.ATTR_QUARTAL, "Квартал", 0, 1)
     MetaDate.GLOBAL_META.add_feature(DateReferent.ATTR_MONTH, "Месяц", 0, 1)
     MetaDate.GLOBAL_META.add_feature(DateReferent.ATTR_WEEK, "Неделя", 0, 1)
     MetaDate.GLOBAL_META.add_feature(DateReferent.ATTR_DAY, "День", 0, 1)
     MetaDate.GLOBAL_META.add_feature(DateReferent.ATTR_HOUR, "Час", 0, 1)
     MetaDate.GLOBAL_META.add_feature(DateReferent.ATTR_MINUTE, "Минут", 0, 1)
     MetaDate.GLOBAL_META.add_feature(DateReferent.ATTR_SECOND, "Секунд", 0, 1)
     MetaDate.GLOBAL_META.add_feature(DateReferent.ATTR_DAYOFWEEK, "День недели", 0, 1)
     MetaDate.POINTER = MetaDate.GLOBAL_META.add_feature(DateReferent.ATTR_POINTER, "Указатель", 0, 1)
     MetaDate.POINTER.add_value(Utils.enumToString(DatePointerType.BEGIN), "в начале", "на початку", "in the beginning")
     MetaDate.POINTER.add_value(Utils.enumToString(DatePointerType.CENTER), "в середине", "в середині", "in the middle")
     MetaDate.POINTER.add_value(Utils.enumToString(DatePointerType.END), "в конце", "в кінці", "in the end")
     MetaDate.POINTER.add_value(Utils.enumToString(DatePointerType.TODAY), "настоящее время", "теперішній час", "today")
     MetaDate.POINTER.add_value(Utils.enumToString(DatePointerType.WINTER), "зимой", "взимку", "winter")
     MetaDate.POINTER.add_value(Utils.enumToString(DatePointerType.SPRING), "весной", "навесні", "spring")
     MetaDate.POINTER.add_value(Utils.enumToString(DatePointerType.SUMMER), "летом", "влітку", "summer")
     MetaDate.POINTER.add_value(Utils.enumToString(DatePointerType.AUTUMN), "осенью", "восени", "autumn")
     MetaDate.POINTER.add_value(Utils.enumToString(DatePointerType.ABOUT), "около", "біля", "about")
     MetaDate.POINTER.add_value(Utils.enumToString(DatePointerType.UNDEFINED), "Не определена", None, None)
     MetaDate.GLOBAL_META.add_feature(DateReferent.ATTR_HIGHER, "Вышестоящая дата", 0, 1)
Пример #3
0
 def images(self) -> typing.List[tuple]:
     res = dict()
     res[Utils.enumToString(TransportKind.FLY)] = PullentiNerCoreInternalResourceHelper.get_bytes("fly.png")
     res[Utils.enumToString(TransportKind.SHIP)] = PullentiNerCoreInternalResourceHelper.get_bytes("ship.png")
     res[Utils.enumToString(TransportKind.SPACE)] = PullentiNerCoreInternalResourceHelper.get_bytes("space.png")
     res[Utils.enumToString(TransportKind.TRAIN)] = PullentiNerCoreInternalResourceHelper.get_bytes("train.png")
     res[Utils.enumToString(TransportKind.AUTO)] = PullentiNerCoreInternalResourceHelper.get_bytes("auto.png")
     res[MetaTransport.IMAGE_ID] = PullentiNerCoreInternalResourceHelper.get_bytes("transport.png")
     return res
Пример #4
0
 def initialize() -> None:
     from pullenti.ner.definition.DefinitionReferent import DefinitionReferent
     MetaDefin._global_meta = MetaDefin()
     MetaDefin._global_meta.add_feature(DefinitionReferent.ATTR_TERMIN, "Термин", 1, 0)
     MetaDefin._global_meta.add_feature(DefinitionReferent.ATTR_TERMIN_ADD, "Дополнение термина", 0, 0)
     MetaDefin._global_meta.add_feature(DefinitionReferent.ATTR_VALUE, "Значение", 1, 0)
     MetaDefin._global_meta.add_feature(DefinitionReferent.ATTR_MISC, "Мелочь", 0, 0)
     MetaDefin._global_meta.add_feature(DefinitionReferent.ATTR_DECREE, "Ссылка на НПА", 0, 0)
     fi = MetaDefin._global_meta.add_feature(DefinitionReferent.ATTR_KIND, "Тип", 1, 1)
     fi.add_value(Utils.enumToString(DefinitionKind.ASSERTATION), "Утверждение", None, None)
     fi.add_value(Utils.enumToString(DefinitionKind.DEFINITION), "Определение", None, None)
     fi.add_value(Utils.enumToString(DefinitionKind.NEGATION), "Отрицание", None, None)
Пример #5
0
 def __str__(self) -> str:
     res = io.StringIO()
     if (not Utils.isNullOrEmpty(self.prep)): 
         print("{0} ".format(self.prep), end="", file=res, flush=True)
     print("{0}(".format(Utils.enumToString(self.typ)), end="", file=res, flush=True)
     if (self.sub_typ != SentItemSubtype.UNDEFINED): 
         print("{0}:".format(Utils.enumToString(self.sub_typ)), end="", file=res, flush=True)
     if (self.source is not None): 
         print(str(self.source), end="", file=res)
         if (self.sub_sent is not None): 
             print(" <= {0}".format(str(self.sub_sent)), end="", file=res, flush=True)
     elif (self.sub_sent is not None): 
         print(str(self.sub_sent), end="", file=res)
     print(')', end="", file=res)
     return Utils.toStringStringIO(res)
Пример #6
0
 def __str__(self) -> str:
     tmp = io.StringIO()
     print("{0}: {1} ".format(self.coef, Utils.enumToString(self.typ)),
           end="",
           file=tmp,
           flush=True)
     if (self.plural == 1):
         print(" PLURAL ", end="", file=tmp)
     elif (self.plural == 0):
         print(" SINGLE ", end="", file=tmp)
     if (self.reverce):
         print(" REVERCE ", end="", file=tmp)
     print("{0}".format(str(self.from0_.source)),
           end="",
           file=tmp,
           flush=True)
     if (self.to_all_list_items):
         print(" ALLLISTITEMS ", end="", file=tmp)
     if (self.to is not None):
         print(" -> {0}".format(str(self.to.source)),
               end="",
               file=tmp,
               flush=True)
     elif (self.to_verb is not None):
         print(" -> {0}".format(str(self.to_verb)),
               end="",
               file=tmp,
               flush=True)
     if (self.alt_link is not None):
         print(" / ALTLINK: {0}".format(str(self.alt_link)),
               end="",
               file=tmp,
               flush=True)
     return Utils.toStringStringIO(tmp)
Пример #7
0
 def __str__(self) -> str:
     tmp = io.StringIO()
     if (self.is_newline_before):
         print("<<", end="", file=tmp)
     print(Utils.enumToString(self.typ).format(),
           end="",
           file=tmp,
           flush=True)
     if (self.value is not None):
         print(" '{0}'".format(self.value), end="", file=tmp, flush=True)
     if (self.ref is not None):
         print(" -> {0}".format(str(self.ref)),
               end="",
               file=tmp,
               flush=True)
     if (self.has_verb):
         print(" HasVerb".format(), end="", file=tmp, flush=True)
     if (self.no_words):
         print(" NoWords", end="", file=tmp)
     if (self.has_table_chars):
         print(" HasTableChars", end="", file=tmp)
     if (self.is_newline_after):
         print(">>", end="", file=tmp)
     print(": {0}".format(self.getSourceText()),
           end="",
           file=tmp,
           flush=True)
     return Utils.toStringStringIO(tmp)
Пример #8
0
 def getImageId(self, obj: 'Referent' = None) -> str:
     from pullenti.ner.org.OrganizationReferent import OrganizationReferent
     if (isinstance(obj, OrganizationReferent)):
         prs = (obj).profiles
         if (prs is not None and len(prs) > 0):
             pr = prs[len(prs) - 1]
             return Utils.enumToString(pr)
     return MetaOrganization.ORG_IMAGE_ID
Пример #9
0
 def initialize() -> None:
     from pullenti.ner.decree.DecreeChangeReferent import DecreeChangeReferent
     MetaDecreeChange.GLOBAL_META = MetaDecreeChange()
     MetaDecreeChange.GLOBAL_META.add_feature(
         DecreeChangeReferent.ATTR_OWNER, "Структурный элемент", 1, 0)
     fi = MetaDecreeChange.GLOBAL_META.add_feature(
         DecreeChangeReferent.ATTR_KIND, "Тип", 1, 1)
     fi.add_value(Utils.enumToString(DecreeChangeKind.APPEND), "Дополнить",
                  None, None)
     fi.add_value(Utils.enumToString(DecreeChangeKind.EXPIRE),
                  "Утратить силу", None, None)
     fi.add_value(Utils.enumToString(DecreeChangeKind.NEW), "В редакции",
                  None, None)
     fi.add_value(Utils.enumToString(DecreeChangeKind.EXCHANGE), "Заменить",
                  None, None)
     fi.add_value(Utils.enumToString(DecreeChangeKind.REMOVE), "Исключить",
                  None, None)
     fi.add_value(Utils.enumToString(DecreeChangeKind.CONSIDER), "Считать",
                  None, None)
     fi.add_value(Utils.enumToString(DecreeChangeKind.CONTAINER),
                  "Внести изменение", None, None)
     MetaDecreeChange.KIND_FEATURE = fi
     MetaDecreeChange.GLOBAL_META.add_feature(
         DecreeChangeReferent.ATTR_CHILD, "Дочернее изменение", 0, 0)
     MetaDecreeChange.GLOBAL_META.add_feature(
         DecreeChangeReferent.ATTR_VALUE, "Значение", 0,
         1).show_as_parent = True
     MetaDecreeChange.GLOBAL_META.add_feature(
         DecreeChangeReferent.ATTR_PARAM, "Параметр", 0,
         1).show_as_parent = True
     MetaDecreeChange.GLOBAL_META.add_feature(
         DecreeChangeReferent.ATTR_MISC, "Разное", 0, 0)
Пример #10
0
 def initialize() -> None:
     from pullenti.ner.sentiment.SentimentReferent import SentimentReferent
     MetaSentiment._global_meta = MetaSentiment()
     f = MetaSentiment._global_meta.addFeature(SentimentReferent.ATTR_KIND,
                                               "Тип", 1, 1)
     MetaSentiment.FTYP = f
     f.addValue(Utils.enumToString(SentimentKind.UNDEFINED), "Неизвестно",
                None, None)
     f.addValue(Utils.enumToString(SentimentKind.POSITIVE), "Положительно",
                None, None)
     f.addValue(Utils.enumToString(SentimentKind.NEGATIVE), "Отрицательно",
                None, None)
     MetaSentiment._global_meta.addFeature(SentimentReferent.ATTR_SPELLING,
                                           "Текст", 0, 0)
     MetaSentiment._global_meta.addFeature(SentimentReferent.ATTR_REF,
                                           "Ссылка", 0, 0)
     MetaSentiment._global_meta.addFeature(SentimentReferent.ATTR_COEF,
                                           "Коэффициент", 0, 0)
Пример #11
0
 def initialize() -> None:
     from pullenti.ner.goods.GoodAttributeReferent import GoodAttributeReferent
     AttrMeta.GLOBAL_META = AttrMeta()
     AttrMeta.GLOBAL_META.typ_attr = AttrMeta.GLOBAL_META.add_feature(
         GoodAttributeReferent.ATTR_TYPE, "Тип", 0, 1)
     AttrMeta.GLOBAL_META.typ_attr.add_value(
         Utils.enumToString(GoodAttrType.KEYWORD), "Ключевое слово", None,
         None)
     AttrMeta.GLOBAL_META.typ_attr.add_value(
         Utils.enumToString(GoodAttrType.CHARACTER), "Качеств.свойство",
         None, None)
     AttrMeta.GLOBAL_META.typ_attr.add_value(
         Utils.enumToString(GoodAttrType.MODEL), "Модель", None, None)
     AttrMeta.GLOBAL_META.typ_attr.add_value(
         Utils.enumToString(GoodAttrType.NUMERIC), "Колич.свойство", None,
         None)
     AttrMeta.GLOBAL_META.typ_attr.add_value(
         Utils.enumToString(GoodAttrType.PROPER), "Имя собственное", None,
         None)
     AttrMeta.GLOBAL_META.typ_attr.add_value(
         Utils.enumToString(GoodAttrType.REFERENT), "Ссылка", None, None)
     AttrMeta.GLOBAL_META.add_feature(GoodAttributeReferent.ATTR_VALUE,
                                      "Значение", 1, 0)
     AttrMeta.GLOBAL_META.add_feature(GoodAttributeReferent.ATTR_ALTVALUE,
                                      "Значание (альт.)", 0, 0)
     AttrMeta.GLOBAL_META.add_feature(GoodAttributeReferent.ATTR_UNIT,
                                      "Единица измерения", 0, 1)
     AttrMeta.GLOBAL_META.add_feature(GoodAttributeReferent.ATTR_NAME,
                                      "Название", 0, 1)
     AttrMeta.GLOBAL_META.add_feature(GoodAttributeReferent.ATTR_REF,
                                      "Ссылка", 0, 1)
Пример #12
0
 def __str__(self) -> str:
     res = io.StringIO()
     if (self.kind != NamedEntityKind.UNDEFINED): 
         print(" [{0}]".format(Utils.enumToString(self.kind)), end="", file=res, flush=True)
     if (self.is_wellknown): 
         print(" (!)".format(), end="", file=res, flush=True)
     if (self.is_in_bracket): 
         print(" [br]".format(), end="", file=res, flush=True)
     if (self.type_value is not None): 
         print(" {0}".format(self.type_value), end="", file=res, flush=True)
     if (self.name_value is not None): 
         print(" \"{0}\"".format(self.name_value), end="", file=res, flush=True)
     if (self.ref is not None): 
         print(" -> {0}".format(str(self.ref)), end="", file=res, flush=True)
     return Utils.toStringStringIO(res)
Пример #13
0
 def initialize() -> None:
     from pullenti.ner.date.DateReferent import DateReferent
     MetaDate.GLOBAL_META = MetaDate()
     MetaDate.GLOBAL_META.addFeature(DateReferent.ATTR_CENTURY, "Век", 0, 1)
     MetaDate.GLOBAL_META.addFeature(DateReferent.ATTR_YEAR, "Год", 0, 1)
     MetaDate.GLOBAL_META.addFeature(DateReferent.ATTR_MONTH, "Месяц", 0, 1)
     MetaDate.GLOBAL_META.addFeature(DateReferent.ATTR_DAY, "День", 0, 1)
     MetaDate.GLOBAL_META.addFeature(DateReferent.ATTR_HOUR, "Час", 0, 1)
     MetaDate.GLOBAL_META.addFeature(DateReferent.ATTR_MINUTE, "Минут", 0,
                                     1)
     MetaDate.GLOBAL_META.addFeature(DateReferent.ATTR_SECOND, "Секунд", 0,
                                     1)
     MetaDate.GLOBAL_META.addFeature(DateReferent.ATTR_DAYOFWEEK,
                                     "День недели", 0, 1)
     MetaDate.POINTER = MetaDate.GLOBAL_META.addFeature(
         DateReferent.ATTR_POINTER, "Указатель", 0, 1)
     MetaDate.POINTER.addValue(Utils.enumToString(DatePointerType.BEGIN),
                               "В начале", "На початку", "In the beginning")
     MetaDate.POINTER.addValue(Utils.enumToString(DatePointerType.CENTER),
                               "В середине", "В середині", "In the middle")
     MetaDate.POINTER.addValue(Utils.enumToString(DatePointerType.END),
                               "В конце", "В кінці", "In the end")
     MetaDate.POINTER.addValue(Utils.enumToString(DatePointerType.TODAY),
                               "Настоящее время", "Теперішній час", "Today")
     MetaDate.POINTER.addValue(Utils.enumToString(DatePointerType.WINTER),
                               "Зимой", "Взимку", "Winter")
     MetaDate.POINTER.addValue(Utils.enumToString(DatePointerType.SPRING),
                               "Весной", "Навесні", "Spring")
     MetaDate.POINTER.addValue(Utils.enumToString(DatePointerType.SUMMER),
                               "Летом", "Влітку", "Summer")
     MetaDate.POINTER.addValue(Utils.enumToString(DatePointerType.AUTUMN),
                               "Осенью", "Восени", "Autumn")
     MetaDate.POINTER.addValue(
         Utils.enumToString(DatePointerType.UNDEFINED), "Не определена",
         None, None)
     MetaDate.GLOBAL_META.addFeature(DateReferent.ATTR_HIGHER,
                                     "Вышестоящая дата", 0, 1)
Пример #14
0
 def to_string(self,
               short_variant: bool,
               lang: 'MorphLang' = None,
               lev: int = 0) -> str:
     res = Utils.newStringIO(self.template)
     vals = list()
     for s in self.slots:
         if (s.type_name == MeasureReferent.ATTR_VALUE):
             if (isinstance(s.value, str)):
                 val = Utils.asObjectOrNull(s.value, str)
                 if (val == "NaN"):
                     val = "?"
                 vals.append(val)
             elif (isinstance(s.value, Referent)):
                 vals.append(s.value.to_string(True, lang, 0))
     for i in range(res.tell() - 1, -1, -1):
         ch = Utils.getCharAtStringIO(res, i)
         if (not str.isdigit(ch)):
             continue
         j = ((ord(ch)) - (ord('1')))
         if ((j < 0) or j >= len(vals)):
             continue
         Utils.removeStringIO(res, i, 1)
         Utils.insertStringIO(res, i, vals[j])
     print(self.out_units(lang), end="", file=res)
     if (not short_variant):
         nam = self.get_string_value(MeasureReferent.ATTR_NAME)
         if (nam is not None):
             print(" - {0}".format(nam), end="", file=res, flush=True)
         for s in self.slots:
             if (s.type_name == MeasureReferent.ATTR_REF
                     and (isinstance(s.value, MeasureReferent))):
                 print(" / {0}".format(s.value.to_string(True, lang, 0)),
                       end="",
                       file=res,
                       flush=True)
         ki = self.kind
         if (ki != MeasureKind.UNDEFINED):
             print(" ({0})".format(Utils.enumToString(ki).upper()),
                   end="",
                   file=res,
                   flush=True)
     return Utils.toStringStringIO(res)
Пример #15
0
 def toString(self, short_variant : bool, lang : 'MorphLang'=None, lev : int=0) -> str:
     res = Utils.newStringIO(self.template)
     vals = list()
     for s in self.slots: 
         if (s.type_name == MeasureReferent.ATTR_VALUE): 
             if (isinstance(s.value, str)): 
                 vals.append(Utils.asObjectOrNull(s.value, str))
             elif (isinstance(s.value, Referent)): 
                 vals.append((s.value).toString(True, lang, 0))
     for i in range(res.tell() - 1, -1, -1):
         ch = Utils.getCharAtStringIO(res, i)
         if (not str.isdigit(ch)): 
             continue
         j = ((ord(ch)) - (ord('1')))
         if ((j < 0) or j >= len(vals)): 
             continue
         Utils.removeStringIO(res, i, 1)
         Utils.insertStringIO(res, i, vals[j])
     uu = self.units
     if (len(uu) > 0): 
         print(uu[0].toString(True, lang, 0), end="", file=res)
         i = 1
         while i < len(uu): 
             pow0_ = uu[i].getStringValue(UnitReferent.ATTR_POW)
             if (not Utils.isNullOrEmpty(pow0_) and pow0_[0] == '-'): 
                 print("/{0}".format(uu[i].toString(True, lang, 1)), end="", file=res, flush=True)
                 if (pow0_ != "-1"): 
                     print("<{0}>".format(pow0_[1:]), end="", file=res, flush=True)
             else: 
                 print("*{0}".format(uu[i].toString(True, lang, 0)), end="", file=res, flush=True)
             i += 1
     if (not short_variant): 
         nam = self.getStringValue(MeasureReferent.ATTR_NAME)
         if (nam is not None): 
             print(" - {0}".format(nam), end="", file=res, flush=True)
         for s in self.slots: 
             if (s.type_name == MeasureReferent.ATTR_REF and (isinstance(s.value, MeasureReferent))): 
                 print(" / {0}".format((s.value).toString(True, lang, 0)), end="", file=res, flush=True)
         ki = self.kind
         if (ki != MeasureKind.UNDEFINED): 
             print(" ({0})".format(Utils.enumToString(ki).upper()), end="", file=res, flush=True)
     return Utils.toStringStringIO(res)
Пример #16
0
 def __str__(self) -> str:
     tmp = io.StringIO()
     if (self.typ != SemFraglinkType.UNDEFINED):
         print("{0} ".format(Utils.enumToString(self.typ)),
               end="",
               file=tmp,
               flush=True)
     if (self.question is not None):
         print("{0}? ".format(self.question), end="", file=tmp, flush=True)
     if (self.source is not None):
         print("{0} ".format(str(self.source)),
               end="",
               file=tmp,
               flush=True)
     if (self.target is not None):
         print("-> {0}".format(str(self.target)),
               end="",
               file=tmp,
               flush=True)
     return Utils.toStringStringIO(tmp)
 def to_string(self,
               short_variant: bool,
               lang: 'MorphLang' = None,
               lev: int = 0) -> str:
     res = io.StringIO()
     typ_ = self.typ
     nam = self.get_string_value(GoodAttributeReferent.ATTR_NAME)
     if (not short_variant):
         if (typ_ != GoodAttrType.UNDEFINED):
             print("{0}{1}: ".format(
                 AttrMeta.GLOBAL_META.typ_attr.
                 convert_inner_value_to_outer_value(
                     Utils.enumToString(typ_), lang),
                 ("" if nam is None else " ({0})".format(nam.lower()))),
                   end="",
                   file=res,
                   flush=True)
     s = self.get_string_value(GoodAttributeReferent.ATTR_VALUE)
     if (s is not None):
         if (typ_ == GoodAttrType.KEYWORD
                 or typ_ == GoodAttrType.CHARACTER):
             print(s.lower(), end="", file=res)
         elif (typ_ == GoodAttrType.NUMERIC):
             vals = self.values
             units_ = self.units
             i = 0
             while i < len(vals):
                 if (i > 0):
                     print(" x ", end="", file=res)
                 print(vals[i], end="", file=res)
                 if (len(vals) == len(units_)):
                     print(units_[i].lower(), end="", file=res)
                 elif (len(units_) > 0):
                     print(units_[0].lower(), end="", file=res)
                 i += 1
         else:
             print(s, end="", file=res)
     re = self.ref
     if (re is not None):
         print(re.to_string(short_variant, lang, 0), end="", file=res)
     return Utils.toStringStringIO(res)