3 SELECT evergreen.upgrade_deps_block_check('1006', :eg_version);
5 -- This function is used to help clean up facet labels. Due to quirks in
6 -- MARC parsing, some facet labels may be generated with periods or commas
7 -- at the end. This will strip a trailing commas off all the time, and
8 -- periods when they don't look like they are part of initials.
9 -- Smith, John => no change
10 -- Smith, John, => Smith, John
11 -- Smith, John. => Smith, John
12 -- Public, John Q. => no change
13 CREATE OR REPLACE FUNCTION metabib.trim_trailing_punctuation ( TEXT ) RETURNS TEXT AS $$
19 last_char = substring(result from '.$');
21 IF last_char = ',' THEN
22 result := substring(result from '^(.*),$');
24 ELSIF last_char = '.' THEN
25 IF substring(result from ' \w\.$') IS NULL THEN
26 result := substring(result from '^(.*)\.$');
33 $$ language 'plpgsql';
35 INSERT INTO config.index_normalizer (name, description, func, param_count) VALUES (
36 'Trim Trailing Punctuation',
37 'Eliminate extraneous trailing commas and periods in text',
38 'metabib.trim_trailing_punctuation',
42 INSERT INTO config.metabib_field_index_norm_map (field,norm,pos)
46 FROM config.metabib_field m,
47 config.index_normalizer i
48 WHERE i.func = 'metabib.trim_trailing_punctuation'
49 AND m.id IN (7,8,9,10);