These modules help manipulate and combine strings.
This module is useful when you need to build a string from multiple substrings, some coded into the Pipe, other parts supplied when the Pipe is run.
String Concatenation lets you define one or more substrings. To get more substrings you simply click the modules plus button. To delete a substring just click the x button to its left.
The Yahoo! Search module lets you enter a Site restriction for the search. This is a URL, but it can be irritating to always have to enter the "http://" part of the URL. Using the String Concatenation module, this example builds the URL from two substrings: the first is "http://" coded directly into the module, the second is the rest of the URL, provided via a wired-in Text Input module.
The output from String Builder is wired into the "Site restriction" section of the Yahoo! Search module, but not directly. String Builder outputs a text value, but the Site restriction section can only accept a url value. We get around this problem by connecting String Builder to a URL Builder module, then wiring its output into Yahoo! Search.
This module works much like the Regex module, but whereas that module operates on each item in a feed, the String Regex module works on a single input string.
Regex is an abbreviation for Regular Expression a powerful pattern-matching notation used to modify text. It's described in more detail in the description of the Regex module.
This example transforms a simple web site name, like "cnn", or "reuters", or "abcnews", into a valid URL. So "cnn" becomes "http://cnn.com".
We use a Text Input module to get the original string (such as "cnn"), then pass this into the String Regex module. Here we write a regular expression rule: "(.+)". The dot (".") is regex short-hand for "match any character". The plus sign ("+") means "match one or more of the preceding character". Combined, ".+" means "match one or more of any character". In practice, this means that the entire input string will be matched.
The second half of the regex rule defines what will happen to whatever part of the input string we matched. Since the entire string is matched, the entire string will be redefined. The second half of the regex is "http://$1.com". The "http://" at the start, and ".com" at the end are simply literal strings - they mean exactly what they say. But what about the $1?
You may have wondered what the parenthesis were for in the first half of our regex: "(.+)". Any part of a regex surrounded by parenthesis is stored in a numbered variable. The first matching parenthesis are $1, the second are $2, and so on, from left to right in the string. If our input string was "reuters", then $1 contains "reuters", and this means our string becomes "http://reuters.com".
Though not directly related to our explanation of the String Regex module, it's useful to look at what we do with the resulting string after it's been transformed. Though the string looks like a URL, it's in fact of type text. We want to use this string as input into the Site restriction field of a Yahoo! Search module. Unfortunately, that field can only receive input of type URL. What do we do?
Fortunately, the URL Builder module can accept a Base URL of type text. So we wire the output from String Regex into a URL Builder module. We leave the Path elements and Query parameters blank. URL Builder outputs a URL type, which can then be wired into Yahoo! Search's Site restriction field.
The URL Builder module is handy whenever you need to coerce a text string into a URL data type.
The String Replace module provides a general string search-and-replace function for your Pipes. You provide the module with the text string to search for, and what to replace it with. Multiple search-and-replace pairs can be added (using the plus button). You can specify to replace all occurences of the search string, or just the first or last occurrence.
This example uses String Replace to filter the user's input into a Yahoo! Search. We don't want the user to search for potentially harmful information, so we replace dangerous terms like explosive, bomb, and gun with benign alternatives like penguin, rabbit, and turtle.
This module splits a string into an array of strings. A delimiter string (often just a single character) tells the module where to split the input string. The delimiter string doesn't appear in the output list.
If this string:
is input into String Tokenizer, and the delimiter is set to "//", it produces four items:
This example connects a text user input module to string tokenizer to create an array of search terms. The term delimiter is a comma. These terms are passed into a Loop module containing a Yahoo! Search sub-module.
The Search sub-module is site restricted to Wikipedia, and the loop is configured to only output the first result for each search.
If you enter the string "frog,vanilla,pulp fiction" into the text input box, the resulting feed will have three items:
This module lets you get just a portion of a string. You enter two numbers to tell the module the starting character position and the length of the resulting substring.
If your input string is "ABCDEFG", then a From value of 2 and length of 4 gives you a resulting string of "CDEF". Notice that the first character in the original string is 0, not 1.
If you enter too long a length, the module just returns a substring to the end of the input string, so if you enter a From of 3 and a length of 100, you'll get a result of "DEFG".
Sometimes it's easier to pick from a numbered list then to enter a value explicitly. And sometimes you just want to limit input options to a pre-selected array of options.
In this example, we create a pseudo-array using the String Concatenate module. We enter three search terms into String Concatenate, and pad them with blank spaces so each string is exactly 12 charactes long:
"shakepeare " "einstein " "roman empire"
We pipe the output of this module into our Sub String module. Next, we use a Number Input module to enter our array index. This gets piped through a couple of Simple Math modules to calculate the offset into our pseudo-array (which is really just a big string). This offset value is then wired into the From value of our Sub String module. Our length value is always 12, because we've made sure to pad each substring out with enough blanks. Finally, the output from Sub String is wired into a Yahoo! Search module.
This module analyzes text piped into it, and tries to find the most significant few words within it. The Term Extractor module can output either a single text string containing all the significant words, or a list of word groupings.
If you opt for a list of results, each resulting item is a set of words that Term Extractor thinks are related. For example, if you input "camels are animals not indigenous to Southern California", Term Extractor returns three items: "camels", "southern california", and "animals". If you chose instead to return output as a single item, it would have simpley been "camels southern california animals".
The Term Extractor module replaces the now-deprecated Content Analysis module.
The Term Extractor is often used as a sub-module within a Loop module. In this example we use Term Extractor to evaluate each item from an input news feed.
The item.description field is fed into Term Extractor by setting the "For each" list box in the Loop module. We select the Loop option to emit all results.
We send this output into another Loop module with a Yahoo! Search sub-module. We have Yahoo! Search look for terms defined in the input list. The end results are those items that matched the words found from Term Extractor.
Translate takes a text item -- such as an element from a feed -- and translates it from one language to another. This module is often used within the Loop module as a sub-module to translate an element of a feed.
Translate can also be used to translate user input. You can wire a Text Input module into Translate to convert, for example, German input into English text before passing the text into a Yahoo! Search module.
You can translate between various languages, including English, French, Japanese, Dutch, German, Greek, Italian, Portuguese, Chinese, Russian, Korean, and Spanish.
This model replaces the now-deprecated BabelFish module.
This example uses Yahoo! Search to find information on Napoleon in the French-language version of Le Monde. Using Translate as a sub-module to Loop, we translate the item.description element into English. The Loop module assigns the translated text back to item.description.
Note that only the description element is translated. To translate other elements, you can add additional Loop/Translate modules.
This module takes a text string as its input, evaluating the words in the text to help categorize it. It can create categories that include PLACE, PERSON, IDENTIFIER (such as phone numbers or email addresses) and CONCEPT. Each of these sub-items contains additional information, such as prediction probability, the start and end character locations where the item was found, and the section of the text that matched the category.
For example, if you feed this text into Yahoo! Shortcuts:
George Washington and his men spent a cold winter in Valley Forge.
Yahoo! Shortcuts will return three items: "cold winter", "George Washington", and "Valley Forge".
"Cold winter" is categorized as a CONCEPT. "George Washington", as expected, is categorized as a PERSON, with a probability of 0.999738. And "Valley Forge" is categorized as a PLACE. The "Valley Forge" category contains additional information, including detailed geocode data (including state, country, latitude, longitude, and zip code).
Yahoo! Shortcuts is most often used as a sub-module inside a Loop module. There it analyzes some element (often the description field) of the input feed.
This example reads the Internet Movie Database's "Born on this Date" feed. This feed is passed into a Loop module with a Yahoo! Shortcuts sub-module. Each item's description element is analyzed by Yahoo! Shortcuts.
Each feed description follows the same pattern: "In [YEAR], [PERSON] was born on this date in [PLACE]." The Shortcuts module creates a PLACE item in the output feed. We then pass the data through a Filter module, which compares the PLACE.title field to a user-provided (via a Text Input module) location.
Finally, we run the data through the Location Extractor module so we can see the finally feed displayed on a map in Pipes Preview.
Use this module any time you need to use sensitive data into your Pipe, such as application IDs, usernames and passwords, in a Pipe that you do not want shared with others.
Private String values will only be shown to the owner of the Pipe and will not be copied if the Pipe is cloned (except by the owner).