⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tagtextwithclassmap.pl

📁 about sound recognition.i want to downlod
💻 PL
字号:
#!/usr/bin/perl -w# This script takes two parameters - a class map and a text file.# It then applies the class map to the given text and sends the# result to standard output.  It expects an unknown word token of# !!UNK in the class map but you could trivially modify this script# to remove this requirement or to change the string used for this# token.# Copyright (c) Gareth Moore 2002use strict;my ($curr_class);  # current classmy (%class);       # word -> class mapmy ($space);       # used to not put extra space on end of linemy ($word);        # current wordif ($#ARGV < 1) {    print "Require two parameters - class map and text file\n";    die "Output is sent to standard out\n";}# Read class mapopen(CMAP, $ARGV[0]);$curr_class = 0;while (<CMAP>) {    if (/^(CLASS\d+)\s/) {        $curr_class = $1;    }    elsif (/\s(\S+)/) {        $class{$1} = $curr_class;    }}close(CMAP);if (!(defined($class{"!!UNK"}))) {    die "No unknown word token found in class map\n";}# Map textopen(TEXT, $ARGV[1]);while (<TEXT>) {    $space = "";    while (s/(\S+)//) {        if (!(defined($class{$1}))) {            $word = "!!UNK";        }        else {            $word = $1;        }        if ($space) {            print " ".$class{$word};        }        else {            print $class{$word};            $space = " ";        }    }    print "\n";}close(TEXT);# Done

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -