Sponsored Content
Top Forums Shell Programming and Scripting Modifying an awk script for syllable splitting Post 302969596 by RudiC on Thursday 24th of March 2016 11:07:00 AM
Old 03-24-2016
Well, THAT is some piece o' code! While just getting a remote idea of how it works and what it does, and not pretending this will be a generally correct solution, adding
Code:
  gsub (/sh/, "&-",a)
  gsub (/ph/, "-&",a)

just above the first while (i = match... will result in
Code:
ashford    ash-ford    1     VCC-CVrC
raphael    ra-pha-el    2     rV-CCV-VC

---------- Post updated at 15:53 ---------- Previous update was at 15:36 ----------

And this will correct for the syllable count:
Code:
  n+=gsub (/sh/, "&-",a)
  n+=gsub (/ph/, "-&",a)

resulting in
Code:
ashford    ash-ford    2     VCC-CVrC
raphael    ra-pha-el    3     rV-CCV-VC

---------- Post updated at 15:57 ---------- Previous update was at 15:53 ----------

Howsoever, with the overall algorithm,YMMV:
Code:
reel    re-el    2     rV-VC
real    re-al    2     rV-VC
cooperation    co-o-pe-ra-ti-on    6     cV-V-CV-rV-CV-VC
Liverpool    Li-ver-po-ol    4     LV-CVr-CV-VC

---------- Post updated at 16:07 ---------- Previous update was at 15:57 ----------

An, not sure if you now like the way it hyphenates shepherd:
Code:
shepherd    sh-e-pherd    3     CC-V-CCVrC

This User Gave Thanks to RudiC For This Post:
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk modifying entries on 2 lines at 2 positions

Hi this script adds text in the correct place on one line only, in a script. awk 'BEGIN{ printf "Enter residue and chain information: " getline var < "-" split(var,a) } /-s rec:/{$7=a; } {print}' FLXDOCK but I need the same info added at position 7 on line 34 and... (1 Reply)
Discussion started by: gav2251
1 Replies

2. Shell Programming and Scripting

modifying a awk line

Hi, I want to print specific columns (from 201 to 1001). The line that I am using is listed below. However I also want to print column 1. So column 1 and 201 to 1001. What modifcations do I need to make? Code: awk -F'\t' 'BEGIN {min = 201; max = 1001 }{for (i=min; i<=max; i++) printf... (5 Replies)
Discussion started by: phil_heath
5 Replies

3. Shell Programming and Scripting

AWK script for programatically modifying java files

Hi, I want to add a String variable to all java classes in my project. Assuming a class like public class Random { String var="Constant string"; ... ... ... } The text in bold is what I want to add to all java files in my workspace. I am an absolute newbie to AWK, and read somewhere that... (5 Replies)
Discussion started by: rocker86
5 Replies

4. UNIX for Dummies Questions & Answers

Understanding / Modifying AWK command

Hey all, So I have an AWK command here awk '{if(FNR==NR) {arr++;next} if($0 in arr) { arr--; if (arr == 0) delete arr;next}{print $0 >"list2output.csv"}} END {for(i in arr){print i >"list1output.csv"}}' list1 list2 (refer to image for a more readable format) This code was submitted... (1 Reply)
Discussion started by: Aussiemick
1 Replies

5. Shell Programming and Scripting

awk script for modifying the file

I have the records in the format one row 0009714494919I MY010727408948010 NNNNNN N PUSAAR727408948010 R007YM08705 9602002 S 111+0360832-0937348 I want to get it int the format 0009714494919I MY010727408948010 NNNNNN N PUSAAR727408948010 R007YM08705 9602002 S ... (2 Replies)
Discussion started by: sonam273
2 Replies

6. Shell Programming and Scripting

Modifying awk code to be inside condition

I have the following awk script and I want to change it to be inside a condition for the file extension. ################################################################################ # abs: Returns the absolute value of a number function abs(val) { return val > 0 ? val \ ... (4 Replies)
Discussion started by: kristinu
4 Replies

7. Shell Programming and Scripting

Need some help modifying script

I have a script that currently runs fine and I need to add or || (or) condition to the if statement and I'm not sure the exact syntax as it relates to the use of brackets. my current script starts like this: errLog="/usr/local/website-logs/error.log" apacheRestart="service httpd restart"... (3 Replies)
Discussion started by: jjj0923
3 Replies

8. Shell Programming and Scripting

Awk: Modifying columns based on comparison

Hi, I have following input in the file in which i want to club the entries based on $1. Also $11 is equal to $13 of other record(where $13 must be on higher side for any $1) then sum all other fields except $11 & $13. Final output required is as follows: INPUTFILE: ... (11 Replies)
Discussion started by: siramitsharma
11 Replies
All times are GMT -4. The time now is 06:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy