Stemming of words that contained affixes by using shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Stemming of words that contained affixes by using shell script
# 15  
Old 05-09-2016
Sorry for disturbing you again. I would like to put the data of file 1 in first field and the data of file 2 in second field and separate between them by <TAB>.

File 1:
Code:
read
like

File 2:
Code:
reading
unlikely

Expected output:
Code:
read<TAB>reading
like<TAB>unlikely
.....

and
Code:
r<TAB>r
e     e
a     a
d     d
$     i
      n
      g
      $ #put sign "$" each final of words

The code that I was tried is:
Code:
awk 'FNR==NR{a[FNR]=$1"\t"; next}{print a[FNR],$1}' root_test.txt affix_test.txt

finally how to put space between of characters?
# 16  
Old 05-09-2016
As much as I like to help: wouldn't it be time to get your act together? Moving targets ALWAYS are difficult if not impossible to hit. What in your own code presented in post#15 did not satisfy you?
@ 1)
Code:
paste file[12]
read    reading
like    unlikely

@ 2) Can't you adapt the proposal in post#8?

Last edited by RudiC; 05-10-2016 at 05:17 AM..
This User Gave Thanks to RudiC For This Post:
# 17  
Old 05-09-2016
Sorry, I'm forgot post #8. The problem has solved. Really thanks you Smilie

Last edited by paranrat; 05-10-2016 at 12:14 AM..
# 18  
Old 05-13-2016
Sorry disturb you again. This one I really stuck because I need to build a lot of fields. What I can do is only build the first field. Others filed gonna blur. What I try to do is matching them first; I=r, I=e, I=a, I=d, B=i, I=n and I=g. After that, get the value before and after r,e,a,d,i,n,g and put them in the right position. If no value put sign "#". Field 7th is in the complete word for "reading" in this case.

Input file:
Code:
r e a d i n g<TAB>I I I I B I I
u n l i k e l y<TAB>I E I I I I B I

The expected output is:
Code:
I # # # # # # r e a d i n g   //'r' is the main character, before 'r' is null and after 'r' are e,a,d,i,n,g
I # # # # # r e a d i n g #   //'e' is the main character, before 'e' is r and after 'e' are a,d,i,n,g
I # # # # r e a d i n g # #   //'a' is the main character, before 'a' are r,e and after 'a' are d,i,n,g
I # # # r e a d i n g # # #   //'d' is the main character, before 'd' are r,e,a and after 'd' are i,n,g
B # # r e a d i n g # # # #   //'i' is the main character, before 'i' are r,e,a,d and after 'i' are n,g
I # r e a d i n g # # # # #   //'n' is the main character, before 'n' are r,e,a,d,i and after 'n' is g
I r e a d i n g # # # # # #   //'g' is the main character, before 'g' are r,e,a,d,i,n and after 'g' is null

This is my trying code and how to loop for the next field?

Code:
awk '
        {
            for (i=1; i<=length($1); i++) print "#"
                for (j=1; j<=1; j++) print substr ($1, j, 1)
                print ""
        }
' $1

The output that I have got:

Code:
#
#
#
#
#
#
#
r

#
#
#
#
#
#
#
#
u

Please guide me, Thanks Smilie

Last edited by paranrat; 05-16-2016 at 04:48 AM..
# 19  
Old 05-16-2016
I don't have the slightest clue of what you're after. To print to one single line instead of new lines for every char, try printf "#" or printf "%s" var
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Python Script for keyword and Stemming

Hello All, I have python script that pulls out a keyword from the data set. The data set contains 3 columns, 1. SysID 2. ID 3. Comment Section. This script just pulls out keyword for certain extent from Comment section and display only keyword, not any other columns. Can someone help... (1 Reply)
Discussion started by: jg355187
1 Replies

2. UNIX for Advanced & Expert Users

Shell script to convert words to Title case

Hi :) I have a .txt file with thousands of words. I was wondering if i could use a simple sed or awk command to convert / replace all words in the text file to Title Case format ? Example: from: this is line one this is line two this is line three to desired output: This Is Line... (8 Replies)
Discussion started by: martinsmith
8 Replies

3. Shell Programming and Scripting

Shell script to read words into an array

Hello, I have output like below: ----------------------------------------------------------------------------- Group 'group1' on system 'system01' is running. ----------------------------------------------------------------------------- Group 'group2' on system 'system01' is running.... (4 Replies)
Discussion started by: sniper57
4 Replies

4. Shell Programming and Scripting

shell prog for double words

I need a shell programing script for "double words" Available Data: This is a shell script that is used to find the ten character words in the machine local dictionary (/usr/dict/words) that are made up with two valid english words that are five character long. This means that each of the... (0 Replies)
Discussion started by: sujithcrazy
0 Replies

5. Shell Programming and Scripting

shell script to print words having first and last character same.

Hi I want to write a shell script to print only those words from a file whose beginning and last character are same. Please help. Thanks, vini (5 Replies)
Discussion started by: vini kumar
5 Replies

6. Shell Programming and Scripting

Shell script to find out words, replace them and count words

hello, i 'd like your help about a bash script which: 1. finds inside the html file (it is attached with my post) the code number of the Latest Stable Kernel, 2.finds the link which leads to the download location of the Latest Stable Kernel version, (the right link should lead to the file... (3 Replies)
Discussion started by: alex83
3 Replies

7. Shell Programming and Scripting

UNIX SHELL taking in 2 words

echo apple orange What command would I use to grab the common letters out of both words? output would be a and e are both common in these 2 words! Please no ruby explanations and please no full answers I just need to know how to get started! Could I sed out a and if the variable =aa... (3 Replies)
Discussion started by: shellmybell
3 Replies

8. Shell Programming and Scripting

how to shift few words of filenames at a time using shell script

Hello everybody, I have some files in directory. I want to shift 3 characters of filenames to the right at a same time. for example, I have filenames like $ls -l 01_2000.G3.input.txt 02_2000.G3.input.txt ..., ..., 04_2010.G3.input.txt I want to change the filenames like... (3 Replies)
Discussion started by: yogeshkumkar
3 Replies

9. Shell Programming and Scripting

how to retrieve the word between 2 specific words with shell script

Hi, I have a file content like: : : <span class="ColorRed"> 1.23</span><br> : : the value 1.23 will be changed from time to time, and I want to use a shell script command, e.g grep or sed, to retrieve only the value, how to do it? Thanks! Victor (6 Replies)
Discussion started by: victorcheung
6 Replies

10. Shell Programming and Scripting

Need to change two words in a line using shell script.

Hi, i have a line tftp dgram udp wait nobody /usr/sbin/tcpd in.tftpd /tftpboott in /etc/inet.conf file. ineed to replace nobody with root and /tftpboott with /flx/boot. i tried using sed ,but i could not change both of them. can you please help me to do this. Edit:... (7 Replies)
Discussion started by: vprasads
7 Replies
Login or Register to Ask a Question