Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Replacing stopwords based on a list Post 302939587 by Walter Misar on Thursday 26th of March 2015 05:01:28 PM
Old 03-26-2015
You can replace multiple words with:
Code:
sed -E 's/(word1|word2|word3)/,/g'

Your sed version might support case insensitive matching:
Code:
sed -E 's/(word1|word2|word3)/,/gI'

Depending on how your list looks like, you can generate the sed statement automatically from your word list (example for comma separated):
Code:
sed -E 's/('`sed 's/,/|/g' wordlist`')/,/gI'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing text based on replacement tables

Dear all, will be grateful for your advices.. The need is (i guess) simple for UNIX experts. Basically, there are replacement tables, which would be used to replace text strings in the data (large volumes..). An exmpl table (a "config file"): VIFIS1_1_PE1836 VIBRIO_FISCHERI VIPAR1_1_PE1662 ... (7 Replies)
Discussion started by: roussine
7 Replies

2. Shell Programming and Scripting

Replacing Character in a file based on element

Hi, I have file like below. Unix:/pclls/turc>cat tibc.property executeReceiver=Y executeSender=Y I want to replace executeSender=N in the file. My file should be like below. executeReceiver=Y executeSender=N I tried with the below command, its giving error. cat tibc.property |... (2 Replies)
Discussion started by: senthil_is
2 Replies

3. UNIX for Dummies Questions & Answers

Script for replacing text in a file based on list

Hi All, I am fairly new to the world of Unix, and I am looking for a way to replace a line of text in a file with a delimited array of values. I have an aliases file that is currently in use on our mail server that we are migrating off of. Until the migration is complete, the server must stay... (8 Replies)
Discussion started by: phoenixjc
8 Replies

4. Shell Programming and Scripting

Replacing headers based on a second file

I have a file with thousands of sequences that looks like this: I need to replace the headers using a second file Thus, I will end up having the following file: I am looking for an AWK script that I can easily plug in my current pipeline. Any help will be greatly appreciated! (6 Replies)
Discussion started by: Xterra
6 Replies

5. Shell Programming and Scripting

Replacing the text in a row based on certain condition

Hi All, I felt tough to frame my question. Any way find my below input. (.CSV file) SNo, City 1, Chennai 2, None 3, Delhi 4,None Note that I have many rows ans also other columns beside my City column. What I need is the below output. SNo, City 1, Chennai 2, Chennai_new 3, Delhi... (2 Replies)
Discussion started by: ks_reddy
2 Replies

6. Shell Programming and Scripting

Finding/replacing strings in some files based on a file

Hi, We have a file (e.g. a .csv file, but could be any other format), with 2 columns: the old value and the new value. We need to modify all the files within the current directory (including subdirectories), so find and replace the contents found in the first column within the file, with the... (9 Replies)
Discussion started by: Talkabout
9 Replies

7. Shell Programming and Scripting

Help with awk replacing identical columns based on another file

Hello, I am using Awk in UBUNTU 12.04. I have a file like following with three fields and 44706 rows. F1 A A F2 G G F3 A T I have another file like this: AL_1 F1 A A AL_2 F1 A T AL_3 F1 A A AL_1 F2 G G AL_2 F2 G A AL_3 F2 G G BO_1 F1 A A BO_2 F1 A T... (6 Replies)
Discussion started by: Homa
6 Replies

8. Shell Programming and Scripting

Replacing a character with a number based on lines

Hi, I am in need of help for the two things which is to be done. First, I have a file that has around four columns. The first column is filled with letter "A". There are around 400 lines in the files as shown below. A 1 5.2 3.2 A 2 0.2 4.5 A 1 2.2 2.2 A 5 2.1 ... (2 Replies)
Discussion started by: begin_shell
2 Replies

9. UNIX for Advanced & Expert Users

Replacing string length based on pattern

Hi All, I have a file which is like below. I need to read all the patterns that starts with P and then replace the 9 digit values to 8 digit values (remove leading integer). Can you please help Example : ( Please look below File) File : P,1 M1,... (7 Replies)
Discussion started by: arunkumar_mca
7 Replies

10. UNIX for Beginners Questions & Answers

Replacing tag based on condition

Hi All, I am having a file like below. The file will having information about the records.If you see the file the file is header and data. For example it have 1 men tag and the tag id will be come after headers. The change is I want to convert All pets tag from P to X. I did a sed like below... (5 Replies)
Discussion started by: arunkumar_mca
5 Replies
Spell(3pm)						User Contributed Perl Documentation						Spell(3pm)

NAME
Pod::Spell -- a formatter for spellchecking Pod SYNOPSIS
% podspell Thing.pm | ispell or if you don't have a podspell: % perl -MPod::Spell -e "Pod::Spell->new->parse_from_file(shift)" Thing.pm |spell |fmt or: % perl -MPod::Spell -e "Pod::Spell->new->parse_from_filehandle" ...which takes POD on STDIN and sends formatted text to STDOUT ...or instead of piping to spell or ispell, use ">temp.txt", and open temp.txt in your word processor for spell-checking. DESCRIPTION
Pod::Spell is a Pod formatter whose output is good for spellchecking. Pod::Spell rather like Pod::Text, except that it doesn't put much effort into actual formatting, and it suppresses things that look like Perl symbols or Perl jargon (so that your spellchecking program won't complain about mystery words like "$thing" or ""Foo::Bar"" or "hashref"). This class provides no new public methods. All methods of interest are inherited from Pod::Parser (which see). The especially interesting ones are "parse_from_filehandle" (which without arguments takes from STDIN and sends to STDOUT) and "parse_from_file". But you can proba- bly just make do with the examples in the synopsis though. This class works by filtering out words that look like Perl or any form of computerese (like "$thing" or ""N>7"" or ""@{$foo}{'bar','baz'}"", anything in C<...> or F<...> codes, anything in verbatim paragraphs (codeblocks), and anything in the stopword list. The default stopword list for a document starts out from the stopword list defined by Pod::Wordlist, and can be supplemented (on a per-document basis) by having "=for stopwords" / "=for :stopwords" region(s) in a document. ADDING STOPWORDS
You can add stopwords on a per-document basis with "=for stopwords" / "=for :stopwords" regions, like so: =for stopwords plok Pringe zorch snik !qux foo bar baz quux quuux This adds every word in that paragraph after "stopwords" to the stopword list, effective for the rest of the document. In such a list, words are whitespace-separated. (The amount of whitespace doesn't matter, as long as there's no blank lines in the middle of the para- graph.) Words beginning with "!" are deleted from the stopword list -- so "!qux" deletes "qux" from the stopword list, if it was in there in the first place. Note that if a stopword is all-lowercase, then it means that it's okay in any case; but if the word has any capital letters, then it means that it's okay only with that case. So a wordlist entry of "perl" would permit "perl", "Perl", and (less interest- ingly) "PERL", "pERL", "PerL", et cetera. However, a wordlist entry of "Perl" catches only "Perl", not "perl". So if you wanted to make sure you said only "Perl", never "perl", you could add this to the top of your document: =for stopwords !perl Perl Then all instances of the word "Perl" would be weeded out of the Pod::Spell-formatted version of your document, but any instances of the word "perl" would be left in (unless they were in a C<...> or F<...> style). You can have several "=for stopwords" regions in your document. You can even express them like so: =begin stopwords plok Pringe zorch snik !qux foo bar baz quux quuux =end stopwords If you want to use E<...> sequences in a "stopwords" region, you have to use ":stopwords", as here: =for :stopwords virtE<ugrave> ...meaning that you're adding a stopword of "virtu". If you left the ":" out, that'd mean you were adding a stopword of "virtE<ugrave>" (with a literal E, a literal <, etc), which will have no effect, since any occurrences of virtE<ugrave> don't look like a normal human- language word anyway, and so would be screened out before the stopword list is consulted anyway. USING Pod::Spell My personal advice: o Write your documentation in Pod. Pod is described in perlpod. And perlmodstyle has some advice on content. This is the stage where you want to make sure you say everything you should, have good and working examples, and have coherent grammar. o Run it through podchecker. This will report all sorts of problems with your Pod; you may choose to ignore some of these problems. Some, like "*** WARNING: Unknown entity E<qacute>...", you should pay attention to. o Once podchecker errors have been tended to, spellcheck the pod by running it through podspell / Pod::Spell. For any misspellings that are reported in the Pod::Spell-formatted text, fix them in the original. Repeat until there's no complaints. o Run it through podchecker again just for good measure. SEE ALSO
Pod::Wordlist Pod::Parser podchecker also known as Pod::Checker perlpod, perlpodspec HINT
If you feed output of Pod::Spell into your word processor and run a spell-check, make sure you're not also running a grammar-check -- because Pod::Spell drops words that it thinks are Perl symbols, jargon, or stopwords, this means you'll have ungrammatical sentences, what with words being missing and all. And you don't need a grammar checker to tell you that. COPYRIGHT AND DISCLAIMER
Copyright (c) 2001 Sean M. Burke. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The programs and documentation in this dist are distributed in the hope that they will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. AUTHOR
Sean M. Burke "sburke@cpan.org" perl v5.8.8 2001-10-27 Spell(3pm)
All times are GMT -4. The time now is 03:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy