s2eps.pl 1005 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/perl
  2. # Copyright 2010-2011 Microsoft Corporation
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  10. # KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  11. # WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  12. # MERCHANTABLITY OR NON-INFRINGEMENT.
  13. # See the Apache 2 License for the specific language governing permissions and
  14. # limitations under the License.
  15. # This script replaces <s> and </s> with <eps> (on both input and output sides),
  16. # for the G.fst acceptor.
  17. while(<>){
  18. @A = split(" ", $_);
  19. if ( @A >= 4 ) {
  20. if ($A[2] eq "<s>" || $A[2] eq "</s>") { $A[2] = "<eps>"; }
  21. if ($A[3] eq "<s>" || $A[3] eq "</s>") { $A[3] = "<eps>"; }
  22. }
  23. print join("\t", @A) . "\n";
  24. }