Separate sentences from two texts, combine them


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Separate sentences from two texts, combine them
# 1  
Old 01-13-2009
Separate sentences from two texts, combine them

I havet two books, one in Swedish, the other in English.
Two text files. I want to combine them into one, with each sentence having it's translation next to it.
------------
Text file one.

Example sentence in English. Example 2 sentence 2 in English 2.
--------------
Text file two.

Examplo sentenco ino Languago. Examplo 2 sentenco2 ino 2 Languaguo 2.

I would like to combine them into one text that reads

result file
-----------------
Example sentence in English.
Examplo sentenco ino Languago.
Example 2 sentence 2 in English 2.
Examplo 2 sentenco2 ino 2 Languaguo 2.
------------------
Right now I am trying to separate the texts into sentences with sed and for simplicity's sake im going to look for sentences as something that ends with a period.


and then connect the lines read from both files with a "for i in $ " bash loop
But I havent done anything more then simple subsitutions, so this is over my head.
Thanks!
# 2  
Old 01-13-2009
Try...
Code:
awk -v RS='\\.' 'NR==FNR{a[NR]=$0;next}{print a[FNR];print}' file1 file2

# 3  
Old 01-13-2009
Thank you!
Looks Like i have to figure out to pre-format the text before I sort it,
need to look into line breaks and such.
Right now some sentences are garbled but I dont think its the regex problem
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Aligning Texts

is there any way to align my text so every column begins on the same line as the previous line? here's my command: printf "THEN ( ${SEARCHPATTB} = Hour = ${CALTOTB} ) %8s => %8s NOW ( ${SEARCHPATT} = Hour = ${CALTOT} ) %7s => %7s Reduced By: %7s -${RESULT}"\\n output i'm currently getting... (2 Replies)
Discussion started by: SkySmart
2 Replies

2. UNIX for Dummies Questions & Answers

Texts between 2 strings

Hi, I have a file with texts shown below, <2013 abc <2013 start request pdu dot1q end pdu response pdu dot1q end pdu am searching for the text "dot1q" , when it matches in the file , i need the contents between "<2013 start" and "end pdu". Can some one help on this ? ... (5 Replies)
Discussion started by: giri_luck
5 Replies

3. Shell Programming and Scripting

How to combine 2 texts file and create another file from it?

Hi all, I've the following hostnames & ip addresses saved in host_ip.txt Based on this list, I need to create the following script. where by HH is a hostname and XXXX is an ip address So the final output would be something like this. Currently, I'm doing it manually, replace, copy... (3 Replies)
Discussion started by: type8code0
3 Replies

4. Shell Programming and Scripting

Combine the lines from separate text files

Hi All, I have three separate text files which has only one line and i want to combine these lines in one text file which will have three lines. cat file1.txt abc cat file2.txt 1265 6589 1367 cat file3.txt 0.98 0.36 0.5 So, I want to see these three lines in the... (9 Replies)
Discussion started by: senayasma
9 Replies

5. Shell Programming and Scripting

extract texts using awk

Hello, I have two files: File1: a b c d File2: b c e I need 'e' as output.... Thanks.. ---------- Post updated at 12:16 PM ---------- Previous update was at 12:15 PM ---------- (1 Reply)
Discussion started by: shekhar2010us
1 Replies

6. Shell Programming and Scripting

Two Huge Texts and Combine Result to Third

hi, i want to examine two file and write some codes to a third file. note that seperators are TAB, not space. first file: 192.168.1.1 3 192.168.1.2 2 192.168.3.2 2 192.168.7.3 1 ... second file: 192.168.1.1 1 10.15.1.1 3 30 10.15.2.1 2 40 192.168.1.1 2 10.23.4.5... (3 Replies)
Discussion started by: gc_sw
3 Replies

7. UNIX for Dummies Questions & Answers

How to filter sentences??

Hi, I have few sentences here. $a1="Division of Hematology-Oncology, and Stem cell transplantation, Schneider Childrens Hospital, Albert Einstein College of Medicine, New Hyde Park, New York. "; $a2="Department of Cell Biology and Anatomy, College of Medicine, National Cheng Kung... (3 Replies)
Discussion started by: vanitham
3 Replies

8. Shell Programming and Scripting

comparing sentences

Hi, I have a file and that file contains the following sentences. Here we show that a virus-encoded transcription factor, viral mRNA, cellular RNA-binding protein heterodimer G3BP/Caprin-1 (p137), translation initiation factors eIF4E and eIF4G, and ribosomal proteins are concentrated in the... (4 Replies)
Discussion started by: vanitham
4 Replies

9. Shell Programming and Scripting

help with a script that will combine two separate scripts for solaris and aix

Hello experts, I have separate scripts (KSH) each for Solaris and AIX to install core applications (e.g. BigBrother). I also have a script called Installer that gives a menu list to select a particular application to install from a bunch of applications. Now I am trying to combine separate... (7 Replies)
Discussion started by: solaix14
7 Replies

10. UNIX for Dummies Questions & Answers

spliting up sentences

hello, i'm looking to split up text into a list of words but can't figure it out, any help would be great. thanks steven (2 Replies)
Discussion started by: stevox
2 Replies
Login or Register to Ask a Question