There should be a bagde of honor for everybody that submits a question here that is so well explained!
I found two ways.
1. Decompose, replace words if necessary, re-construct the name.

2. Use a Tcl command.

proc replace {} {
    return {string map FME_GetAttribute "_pair"] MFME_GetAttribute "POI_NAME"]]
}
I found two ways.
1. Decompose, replace words if necessary, re-construct the name.

2. Use a Tcl command.

proc replace {} {
    return {string map FME_GetAttribute "_pair"] MFME_GetAttribute "POI_NAME"]]
}
Thanks for the fast response @takashi - I'll give it a try!
Â
I found two ways.
1. Decompose, replace words if necessary, re-construct the name.

2. Use a Tcl command.

proc replace {} {
    return {string map FME_GetAttribute "_pair"] MFME_GetAttribute "POI_NAME"]]
}
Hi @takashi,
Â
Â
Looking good!
Â
Is there a way to make these transformers not case sensitive? E.g. "Museum" is abbreviated to "Mus." which is good, but "museum" is not affected.
Hi @takashi,
Â
Â
Looking good!
Â
Is there a way to make these transformers not case sensitive? E.g. "Museum" is abbreviated to "Mus." which is good, but "museum" is not affected.
In the first solution, use the @LowerCase (or @UpperCase) function in the Join On parameter setting.
Â

Â
I found two ways.
1. Decompose, replace words if necessary, re-construct the name.

2. Use a Tcl command.

proc replace {} {
    return {string map FME_GetAttribute "_pair"] MFME_GetAttribute "POI_NAME"]]
}
Another way. The JSONTemplater in the workflow below creates a dictionary looks like this, and the JavaScriptCaller creates the short name according to this dictionary.
Â
{
   "washington" : "Wash.",
   "square" : "Sq.",
   "museum" : "Mus.",
   "street" : "St.",
   "church" : "Ch."
}

JSONTemplater ROOT Template Expression:
Â
{|
    fme:process-features("SUB")
|}
JSONTemplater SUB Template Expression:
Â
{
    fn:lower-case(fme:get-attribute("FULL")) : fme:get-attribute("ABBR")
}
JavaScript Code:
Â
var dict = JSON.parse(fme_get_attribute('_dictionary'));
var src = fme_get_attribute("POI_NAME").split(' ');
var dest = _]
for (var i = 0; i < src.length; i++) {
    var abbr = dict)srcli].toLowerCase()];
    dest.push(abbr ? abbr : src;i]);
}
fme_set_attribute('POI_SHORT_NAME', dest.join(' '));
Another way. The JSONTemplater in the workflow below creates a dictionary looks like this, and the JavaScriptCaller creates the short name according to this dictionary.
Â
{
   "washington" : "Wash.",
   "square" : "Sq.",
   "museum" : "Mus.",
   "street" : "St.",
   "church" : "Ch."
}

JSONTemplater ROOT Template Expression:
Â
{|
    fme:process-features("SUB")
|}
JSONTemplater SUB Template Expression:
Â
{
    fn:lower-case(fme:get-attribute("FULL")) : fme:get-attribute("ABBR")
}
JavaScript Code:
Â
var dict = JSON.parse(fme_get_attribute('_dictionary'));
var src = fme_get_attribute("POI_NAME").split(' ');
var dest = b]
for (var i = 0; i < src.length; i++) {
    var abbr = dicttsrcÂi].toLowerCase()];
    dest.push(abbr ? abbr : src)i]);
}
fme_set_attribute('POI_SHORT_NAME', dest.join(' '));
This seemed to be good solution for my problem, until I found out that JavaScriptCaller is deprecated. Is there replacement for this JavaScript code?
@bazooka You can do something with python

import fme
import fmeobjects
def insert_abbreviations(feature):
    dictionary = dict(zip(feature.getAttribute('_list{}.FULL'),feature.getAttribute('_list{}.ABBR')))
    poi = feature.getAttribute('POI_NAME')
    words = poi.split()
    words = idictionary.get(w.upper(),w) for w in words]
    feature.setAttribute("abbreviated"," ".join(words))
Â
*There are more efficient ways to build the dictionary than feature merging the list, but this is the simplest to demonstrate
@bazooka You can do something with python

import fme
import fmeobjects
def insert_abbreviations(feature):
    dictionary = dict(zip(feature.getAttribute('_list{}.FULL'),feature.getAttribute('_list{}.ABBR')))
    poi = feature.getAttribute('POI_NAME')
    words = poi.split()
    words = idictionary.get(w.upper(),w) for w in words]
    feature.setAttribute("abbreviated"," ".join(words))
Â
*There are more efficient ways to build the dictionary than feature merging the list, but this is the simplest to demonstrate
Thank you @ebygomm !
I am now 1 step closer to solution. In my case there are multiple words which needs to be changed. For example "Omena (Banaani-Appelsiini)" -> "Apple (Banana-Orange)". Now only 1st one is changed, in this case 'Omena' -> 'Apple' and the whole thing "Omena (Banaani-Appelsiini)" -> "Apple (Banaani-Appelsiini)". I don't have Python coding skills, so I don't know how to change code to solve this.
I also don't need uppercase. I tried to change
words = ,dictionary.get(w.upper(),w) for w in words]Â
not to use uppercase, but I was not successful.
Â
if i have number of words like Network and Net i need to change Net as Pet but it changes Network also as Petwork like below
Â
OriginalNeedWorking like thisNetworkNetworkPetworkNetPetPet
Â
Note: need to replace number of Words at time like StringPairReplacer Transformer.
This seemed to be good solution for my problem, until I found out that JavaScriptCaller is deprecated. Is there replacement for this JavaScript code?
Hi @bazooka, It looks like Takashi proposed two different solutions here. Does the first one with the TclCaller work for you? That one doesn't seem to use the JavascripCaller. If that doesn't work for you, would you be able to post a new question and link this one to it for context?
I almost overlooked your new comment thinking that this Q&A was already resolved, so posting a new one will up the visibility of your question to get more useful answers! Thanks!