Sponsored Content
Top Forums Shell Programming and Scripting CREATING A SYLLABLE CONCORDANCE WITH POSITIONAL VARIANTS Post 302543707 by gimley on Monday 1st of August 2011 10:46:36 PM
Old 08-01-2011
Hello,
With a little help from colleagues, I finally managed to get the concordance going. Here is the code in case someone else would like to use it:
Code:
#! /usr/bin/perl

use strict;  # These two lines save you endless trouble
use warnings; # without them typos and such errors get missed

open (my $corpus_file, '<', 'Corpus'); # Created a test corpus with just the contained lines
# $/="\r\n"; # Again with the DOS files
chomp(my @corpus = (<$corpus_file>)); # Load the corpus file into an array for faster access
open (my $syllables_file, '<', 'Syllables');
while(<$syllables_file>){
    chomp(my $syllable = $_);
    my $count = 0;
    my $init = my $med = my $fin = my $stdalone = "NONE";
    for my $word (@corpus) {
        if ( $word =~ /^$syllable.+/) {
            if ($init eq "NONE") {
                $init = $word;
                $count++;
            }
        }
        elsif ($word =~ /.+$syllable.+/) {
            if ($med eq "NONE") {
                $med = $word;
                $count++;
            }
        }
        elsif ($word =~ /.+$syllable$/) {
            if ($fin eq "NONE") {
                $fin = $word;
                $count++;
            }
        }
        elsif ($word =~ /^$syllable$/) {
            if ($stdalone eq "NONE") {
                $stdalone = $word;
                $count++;
            }
        }
        last if $count == 4;
    }
    print "$syllable\nInitial $init\nMedial $med\nFinal $fin\nStandalone $stdalone\n";
    #print "$init\t$med\t$fin\t$stdalone\n";
}

Many thanks for the information re. Regex.

Last edited by Scott; 08-02-2011 at 01:14 AM.. Reason: Code tags, please...
 

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creating a syllable concordance

Hello, I have two files. The first file contains specific syllables of a language (Hindi) and the second file contains a large database from which these syllables have been culled. The syllable file which has syllables in Hindi has one syllable per line and the corpus file has a data... (8 Replies)
Discussion started by: gimley
8 Replies

2. Shell Programming and Scripting

[All variants] remove first pair of parentheses

How to remove first pair of parentheses and content in them from the beginning of the line? Here's the list: (ok)-test (ok)-test-(ing) (some)-test-(ing)-test test-(ing) Desired result: test test-(ing) test-(ing)-test test-(ing) Here's what I already tried with GNU sed: sed -e... (6 Replies)
Discussion started by: useretail
6 Replies

3. Shell Programming and Scripting

Writing a clustering concordance for a Perso-Arabic script

I am working on a database of a language using Arabic Script. One of the major issues is that the shape of the characters changes according to their initial, medial or final positioning. Another major issue is that of the clustering of vowels within the word: the clustering changes totally the... (9 Replies)
Discussion started by: gimley
9 Replies

4. Shell Programming and Scripting

[All variants] Change settings

Hi, I have a big settings confg (file attached). There are a few separate tasks that I have to accomplish. All scripting/programming languages are appreciated. 1. I need to parse all values and output to stdout. Sample output (truncated): VALUEA 2017-01-01 Lores ipsum Lorem ipsum dolor sit... (11 Replies)
Discussion started by: useretail
11 Replies

5. UNIX for Beginners Questions & Answers

Merge 4 bim files by keeping only the overlapping variants (unique rs values )

Dear community, I am facing a problem and I kindly ask your help: I have 4 different data sets consisted from 3 different types of array. On each file, column 1 is chromosome position, column 2 is SNP id etc... Lets say I have the following (bim) datasets: x2014: 1 rs3094315... (4 Replies)
Discussion started by: fondan
4 Replies
Test::Corpus::Audio::MPD(3pm)				User Contributed Perl Documentation			     Test::Corpus::Audio::MPD(3pm)

NAME
Test::Corpus::Audio::MPD - automate launching of fake mdp for testing purposes VERSION
version 1.120990 SYNOPSIS
use Test::Corpus::Audio::MPD; # die if error [...] stop_test_mpd(); DESCRIPTION
This module will try to launch a new mpd server for testing purposes. This mpd server will then be used during POE::Component::Client::MPD or Audio::MPD tests. In order to achieve this, the module will create a fake mpd.conf file with the correct pathes (ie, where you untarred the module tarball). It will then check if some mpd server is already running, and stop it if the "MPD_TEST_OVERRIDE" environment variable is true (die otherwise). Last it will run the test mpd with its newly created configuration file. Everything described above is done automatically when the module is "use"-d. Once the tests are run, the mpd server will be shut down, and the original one will be relaunched (if there was one). Note that the test mpd will listen to "localhost", so you are on the safe side. Note also that the test suite comes with its own ogg files. Those files are 2 seconds tracks recording my voice saying ok, and are freely redistributable under the same license as the code itself. In case you want more control on the test mpd server, you can use the supplied public methods. This might be useful when trying to test connections with mpd server. METHODS
customize_test_mpd_configuration( [$port] ); Create a fake mpd configuration file, based on the file mpd.conf.template located in share subdir. The string PWD will be replaced by the real path (ie, where the tarball has been untarred), while TMP will be replaced by a new temp directory. The string PORT will be replaced by $port if specified, 6600 otherwise (MPD's default). my $dir = playlist_dir(); Return the temp dir where the test playlists will be stored. start_test_mpd(); Start the fake mpd, and die if there were any error. stop_test_mpd(); Kill the fake mpd. SEE ALSO
You can look for information on this module at: o Search CPAN http://search.cpan.org/dist/Test-Corpus-Audio-MPD <http://search.cpan.org/dist/Test-Corpus-Audio-MPD> o See open / report bugs http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Corpus-Audio-MPD <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Corpus-Audio-MPD> o Mailing-list (same as Audio::MPD) http://groups.google.com/group/audio-mpd <http://groups.google.com/group/audio-mpd> o Git repository http://github.com/jquelin/test-corpus-audio-mpd <http://github.com/jquelin/test-corpus-audio-mpd> o AnnoCPAN: Annotated CPAN documentation http://annocpan.org/dist/Test-Corpus-Audio-MPD <http://annocpan.org/dist/Test-Corpus-Audio-MPD> o CPAN Ratings http://cpanratings.perl.org/d/Test-Corpus-Audio-MPD <http://cpanratings.perl.org/d/Test-Corpus-Audio-MPD> AUTHOR
Jerome Quelin COPYRIGHT AND LICENSE
This software is copyright (c) 2009 by Jerome Quelin. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-15 Test::Corpus::Audio::MPD(3pm)
All times are GMT -4. The time now is 01:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy