Project

General

Profile

« Previous | Next » 

Revision 7442

redmine_synonyms: Added support for ambiguous terms, which unlike the synonyms format nests the term (the alternative) under the synonym (the ambiguous term) rather than the synonym under the term. Note that ambiguous terms must also be prefixed with ? to differentiate them from composites (e.g. recordedBy_givenName), which use the same _-based naming convention.

View differences:

bin/redmine_synonyms
6 6

  
7 7
sed () { "$(which sed)" -"$sedEreFlag" "$@";}
8 8

  
9
ambigTerm=
10
ambigPrefix=
9 11
term=
10
sed -n 's/^.*<h([1-3])[^>]*><a href="#[^>]+>([^<]+).*$/\1 \2/p'\
12
sed -n 's/^.*<h([1-4])[^>]*><a href="#[^>]+>([^<]+).*$/\1 \2/p'\
11 13
|while read -r line; do
12 14
    set -- $line # split using IFS
13 15
    level="$1" name="$2"
16
    
17
    # Handle synonyms
14 18
    if test "$level" = 3; then echo "$name	$term"
15
    else term="$name"
19
    else
20
        term="$name"
21
        
22
        # Handle ambiguous terms
23
        termName="${term#\?}"
24
        if test "$termName" != "$term"; then # ambiguous term (starts with ?)
25
            ambigTerm="$term"
26
            ambigPrefix="${termName}_"
27
        elif test -n "$ambigTerm" -a "${term#$ambigPrefix}" != "$term"; then
28
            # alternative of ambiguous term (starts with $ambigTerm)
29
            echo "$ambigTerm	$term"
30
        else # term not related to ambiguous terms
31
            ambigTerm= ambigPrefix= # clear any ambiguous term in effect
32
        fi
16 33
    fi
17 34
done

Also available in: Unified diff