Skip to main content

Hello friends, @takashi @imj @egomm @gio @david_r

I have an attribute filled with river names, but some are abbreviated and i need to write out them.

eg:

  1. Rch. das Pedras Negras >> Riacho das Pedras Negras
  2. Rib. da Saudade >> Ribeirão da Saudade
  3. Córr. da Cachoeira >> Córrego da Cachoeira

I use StringReplacer to match each short text, but, in this way, i've to put one StringReplacer for each short text. I saw in forum some topics about regular expressions (i don't have expertise in RegEx,so i've to begin studying it) with StringReplacer and i figure out to use only one StringReplacer to replace all of short texts.

Is there a way to do this with stringreplacer using regular expressions? I do some tests using this parameters:

  • Attributes: text_line_data
  • Text to find: (^Córr.)|(^Rib.)|(^Rb.)|(^Rch.)|(^Cach.)
  • Replacement Text:
  • Use Regular Expressions: yes
  • CaseSensitive: no

With this parameters i can isolate the short texts, but now i need a regular expression that replace the short texts for full texts.

Thanks for all!!

You're on the right track, but my advice is to use one StringReplacer for each abbreviation, e.g.

Text to find:     ^Córr.
Replacement text: Córrego
Text to find:     ^Rib.
Replacement text: Ribeirão

Notice that you do not need to use paranthesis here.

Then just chain the StringReplacers together, one after another.


You're on the right track, but my advice is to use one StringReplacer for each abbreviation, e.g.

Text to find:     ^Córr.
Replacement text: Córrego
Text to find:     ^Rib.
Replacement text: Ribeirão

Notice that you do not need to use paranthesis here.

Then just chain the StringReplacers together, one after another.

Thanks @david_r 

I just using one for each abbreviation like your e.g. but i'd like to find a way to use only one StringReplacer to relieve my workspace because there are a lot of abbreviations (imagine all features of cartography :) ) to replace.


Hi @franciscocamell, the StrintPairReplacer might help you.

  • Replacement Pairs: Rch. Riacho Rib. Ribeirão Córr. Córrego

Could you use the AttributeManager? Open the text editor for an attribute and make use of the ReplaceRegEx or ReplaceString string functions.

That way you could make all the changes in a single AttributeManager.


Hi @franciscocamell, the StrintPairReplacer might help you.

  • Replacement Pairs: Rch. Riacho Rib. Ribeirão Córr. Córrego

If you want to make all the replacements in one transformer this is the best way imo.


i would go for a stringreplacer, stringpairreplacer or a stringmapper (tcl)

Stringpairreplacer if you don't have many mapppings, like in your (Fransisco's) case.

Stringmapper allows for full regex searching.

Stringreplacer for limited regex.


If you have a lot of mappings you can maintain in a spreadsheet or similar. Create the the replacement pairs string in a parent workspace, and then send as a parameter to be used in a stringpairreplacer in the child workspace.


Or, if you are confident that all abbreviations are at the start and finish with a full stop

A string searcher with the regular expression ^.+\\. to store the abbreviation.

A featuremerger merging this data on abbreviation with a list of all abbreviations and full text

A stringreplacer to search for the abbreviation in the original name and replace with the full text attribute

Additional abbreviations can then easily be added to the worksheet without having to change any workbench transformers


Thanks @david_r

I just using one for each abbreviation like your e.g. but i'd like to find a way to use only one StringReplacer to relieve my workspace because there are a lot of abbreviations (imagine all features of cartography 🙂 ) to replace.

I see, in that case I'd look into the solution posted by @egomm below (the one with the FeatureMerger).


Hi @franciscocamell, the StrintPairReplacer might help you.

  • Replacement Pairs: Rch. Riacho Rib. Ribeirão Córr. Córrego

Hello @takashi, thanks for your help, i tried the StringPairReplacer and fits well, but i guess the @egomm way using a worksheet to feed my workspace with the abbreviations it'll be more powerfull against the quantity of data that i've to convert.


Or, if you are confident that all abbreviations are at the start and finish with a full stop

A string searcher with the regular expression ^.+\\. to store the abbreviation.

A featuremerger merging this data on abbreviation with a list of all abbreviations and full text

A stringreplacer to search for the abbreviation in the original name and replace with the full text attribute

Additional abbreviations can then easily be added to the worksheet without having to change any workbench transformers

Hello @egomm

I'm trying your way with a worksheet feeding a transformer and it worked. I'm a begginer in the RegEx, as i said, and i'd like that you explains this regular expression ^.+\\.

 

Thanks for your attention.

^.+\\.

^begin of line i(in this conext) For instance (^Me) means not Me...

.+ one or more characters (dot matches any single characer anf the + means one or more)

\\. literal dot ( the \\ is an escape else the dot wil match any character)

Results in 1st string from the start of line that ends with a dot.


Reply