create or replace function abbr_replace ( str varchar2 )
return varchar2 deterministic as
begin
return replace(
replace(
replace(
replace(
replace( lower( str ), 'preparatory', 'prep' ),
'junior', 'jr'),
'elementary school', 'es'),
'alternative', 'alt' ),
'elementary school', 'es'
);
end abbr_replace;
Function created.
create table source1 (
name varchar2(100),
replace_name varchar2(100) as (
cast ( abbr_replace ( name ) as varchar2(100) )
)
)
Table created.
create table source2 (
name varchar2(100),
replace_name varchar2(100) as (
cast ( abbr_replace ( name ) as varchar2(100) )
)
)
Table created.
insert into source1 (name) values ('Adda Clevenger Jr Prep School')
1 row(s) inserted.
insert into source1 (name) values ('Alice Fong Yu Alt School')
1 row(s) inserted.
insert into source1 (name) values ('Convent Of Sacred Heart Es')
1 row(s) inserted.
insert into source1 (name) values ('Rosa Parks Elementary School')
1 row(s) inserted.
insert into source2 (name) values ('Adda Clevenger Junior Preparatory School')
1 row(s) inserted.
insert into source2 (name) values ('Alice Fong Yu Alternative School')
1 row(s) inserted.
insert into source2 (name) values ('Convent of Sacred Heart Elementary School')
1 row(s) inserted.
insert into source2 (name) values ('Rosa Parks Elementary School')
1 row(s) inserted.
commit
Statement processed.
select s1.name, s2.name
from source1 s1
join source2 s2
on s2.replace_name = s1.replace_name
NAME | NAME |
---|---|
Adda Clevenger Jr Prep School | Adda Clevenger Junior Preparatory School |
Alice Fong Yu Alt School | Alice Fong Yu Alternative School |
Convent Of Sacred Heart Es | Convent of Sacred Heart Elementary School |
Rosa Parks Elementary School | Rosa Parks Elementary School |
select s1.name, s2.name, utl_match.jaro_winkler(s1.name, s2.name) jw
from source1 s1
join source2 s2
on utl_match.jaro_winkler(s1.name, s2.name) > .9
NAME | NAME | JW |
---|---|---|
Adda Clevenger Jr Prep School | Adda Clevenger Junior Preparatory School | 9.0362068965517239E-001 |
Alice Fong Yu Alt School | Alice Fong Yu Alternative School | 9.2500000000000004E-001 |
Convent Of Sacred Heart Es | Convent of Sacred Heart Elementary School | 9.0168855534709191E-001 |
Rosa Parks Elementary School | Rosa Parks Elementary School | 1.0E+000 |