Архив

Публикации с меткой ‘UTL_MATCH.JARO_WINKLER_SIMILARITY’

Определение строк со смешанными языками (русские и английские буквы)

2 Сентябрь 2010 Нет комментариев

Вытаскиваем записи, у которых есть хотя бы одна нерусская буква

with t as
(
 select 1 id, 'Сидоров' s from dual
  union all
 select 2, 'Cидoров' from dual
  union all
 select 3, 'Пирогов' from dual
)
select * from t t0
where soundex(t0.s) is not null;

        ID S
---------- -------
         2 Cидoров

Предположительные совпадения (Пирогов добавлен для показательности неточности подхода)

with t as
(
 select 1 id, 'Сидоров' s from dual
  union all
 select 2, 'Cидoров' from dual
  union all
 select 3, 'Пирогов' from dual
)
select * from t t0, t t1
where UTL_MATCH.JARO_WINKLER_SIMILARITY(t0.s,t1.s)>=70
      and soundex(t0.s) is null
      and soundex(t1.s) is not null
      and t0.id<>t1.id;

        ID S               ID S
---------- ------- ---------- -------
         1 Сидоров          2 Cидoров
         3 Пирогов          2 Cидoров

Простой translate для вытаскивания совпадающих написаний

with t as
(
 select 1 id, 'Сидоров' s from dual
  union all
 select 2, 'Cидoров' from dual
  union all
 select 3, 'Пирогов' from dual
)
select * from t t0, t t1
where translate(t1.s,'AaBbCcEegHKkMmOoPpTuXxy','АаВьСсЕедНКкМтОоРрТиХху')=t0.s
      and t0.id<>t1.id;

        ID S               ID S
---------- ------- ---------- -------
         1 Сидоров          2 Cидoров

Вывести данные в одном языке (латиница или кирилица) + цифры и знак подчёрка:

with t as
(
 select 'Сидоров' val from dual
  union all
 select 'Cидoров' from dual
  union all
 select 'Пирогов' from dual
  union all
 select 'ASD_1' from dual 
  union all
 select 'ASD_1Я' from dual  
)
select val from t
where regexp_like(val, '^([A-z]|[0-9]|_)+$') or regexp_like(val, '^([А-я]|[0-9]|_)+$')
/

VAL
-------
Сидоров
Пирогов
ASD_1