The regular expression construct \p{ name } is not working in ruby - ruby-on-rails

I am trying the regular expression construct
like \p{IsGreek} and \p{IsBasicLatin}
but I am getting this error
config/initializers/app_constants.rb:13: invalid character property
name {IsBasicLatin}

It seems like Ruby does not support Unicode Blocks, but it does support Properties and Scripts. See Character Properties on ruby-doc.org.
That means you can use the Unicode scripts:
\p{Latin}
\p{Greek}
For an introduction to Unicode Properties, Scripts and Blocks you can have a look at regular-expressions.info

Try the following instead:
\p{Greek}
\p{Latin}
Documentation here:
http://ruby-doc.org/core-2.0/Regexp.html

Ruby 2.0 adds support for Unicode blocks:
$ ruby-1.9.3-p484/bin/ruby -e "p /\p{InBasicLatin}/"
-e:1: invalid character property name {InBasicLatin}: /\p{InBasicLatin}/
$ ruby-2.0.0-p353/bin/ruby -e "p /\p{InBasicLatin}/"
/\p{InBasicLatin}/
Note that you have to use In, not Is.

Related

Lua is throwing error when Vim keymap includes "\"

I am recently migrating from vimscript to lua with Nvim. While converting the keymappings, I ran into a problem with the following keymap:
[ init.vim ]
tmap <leader>e <C-\><C-n>
[ init.lua ] ( error )
map('t','<leader>e','<C-\><C-n>')
Whenever I reload with above keymap, Nvim will throw the following error:
I'm assuming that "\" might be the problem. If so, how do I refactor the keymap properly for it to work? Any feedback will be greatly appreciated.
It is most likely as the \ is used to escape special characters in the string. Try putting
map('t','<leader>e','<C-\\><C-n>')
This way you are telling Lua that you want the backslash character and not some other special character.

Doesn’t look like a character based (Bytes Are All You Need) model (DeepSpeech)

I have been following DeepSpeech documentation in order to build my own scorer. After implementing this blocks of code
cd data/lm
python3 generate_lm.py --input_txt vocabulary.txt --output_dir .
–top_k 1500 --kenlm_bins path/to/kenlm/build/bin/
–arpa_order 3 --max_arpa_memory “50%” --arpa_prune “0|0|1”
–binary_a_bits 255 --binary_q_bits 8 --binary_type trie
curl -LO http://github.com/mozilla/DeepSpeech/releases/…
tar xvf native_client.*.tar.xz
./generate_scorer_package --alphabet …/alphabet.txt --lm lm.binary --vocab vocab-1500.txt
–package kenlm.scorer --default_alpha 0.931289039105002 --default_beta 1.1834137581510284
I get the following errors:
Doesn’t look like a character based (Bytes Are All You Need) model.
–force_bytes_output_mode was not specified, using value infered from vocabulary contents: false
Error: Can’t parse scorer file, invalid header. Try updating your scorer file.
Error loading language model file: Invalid magic in trie header.
I want to mention that I use a different alphabet that also contains other characters besides english characters.
This error is usually encountered with non-English alphabets. You can overcome the error by using the --force_bytes_output_mode parameter when calling generate_scorer_package. I pushed a change to the PlayBook this morning which covers this error.

How parse Perl 6 code using STD.pm6 grammar?

I would like minimal working example of parsing Perl 6 code from Perl 6 using STD.pm6
Running something like this
use v6;
use STD.pm6;
my $j = slurp 'e:\src\perl6\valid-p6-script.p6';
my $o = STD::Grammar.parse($j);
say $o.perl;
under debugger give me absolutely weird output:
e:\src\prg\perl6>c:\rakudo\bin\perl6-debug-m.bat -I. p6.p6
>>> LOADING p6.p6
>>> LOADING E:\src\prg\perl6\STD.pm6
Unhandled exception: ctxlexpad needs an MVMContext
at gen/moar/m-CORE.setting:15136 (C:\rakudo/share/perl6/runtime/CORE.setting.moarvm::24)
from gen/moar/m-CORE.setting:15250 (C:\rakudo/share/perl6/runtime/CORE.setting.moarvm:AT-KEY:95)
from gen/moar/m-CORE.setting:4291 (C:\rakudo/share/perl6/runtime/CORE.setting.moarvm:postcircumfix:<{ }>:4294967295)
from C:\rakudo/share/perl6/lib/Debugger/UI/CommandLine.pm:736 (C:\rakudo\share\perl6\lib\Debugger\UI\CommandLine.pm.mo
arvm::82)
from gen/moar/m-CORE.setting:2826 (C:\rakudo/share/perl6/runtime/CORE.setting.moarvm:sink-all:168)
from gen/moar/m-CORE.setting:10187 (C:\rakudo/share/perl6/runtime/CORE.setting.moarvm:sink:36)
from C:\rakudo/share/perl6/lib/Debugger/UI/CommandLine.pm:730 (C:\rakudo\share\perl6\lib\Debugger\UI\CommandLine.pm.mo
arvm:unhandled:114)
from C:\rakudo/share/perl6/lib/Debugger/UI/CommandLine.pm:721 (C:\rakudo\share\perl6\lib\Debugger\UI\CommandLine.pm.mo
arvm::25)
from gen/moar/m-Metamodel.nqp:3586 (C:\rakudo\share\nqp\lib/Perl6/Metamodel.moarvm:enter:28)
from gen/moar/m-CORE.setting:5190 (C:\rakudo/share/perl6/runtime/CORE.setting.moarvm:CALL-ME:57)
from gen/moar/m-BOOTSTRAP.nqp:2749 (C:\rakudo/share/nqp/lib/Perl6/BOOTSTRAP.moarvm::93)
from gen\moar\stage2\NQPHLL.nqp:1425 (C:\rakudo\share\nqp\lib/NQPHLL.moarvm:command_eval:380)
from src/Perl6/Compiler.nqp:59 (C:\rakudo\share\nqp\lib/Perl6/Compiler.moarvm:command_eval:93)
from gen\moar\stage2\NQPHLL.nqp:1365 (C:\rakudo\share\nqp\lib/NQPHLL.moarvm:command_line:114)
from gen/moar/m-perl6-debug.nqp:497 (C:\rakudo\share\perl6\runtime\perl6-debug.moarvm:MAIN:190)
from gen/moar/m-perl6-debug.nqp:440 (C:\rakudo\share\perl6\runtime\perl6-debug.moarvm:<mainline>:68)
from <unknown>:1 (C:\rakudo\share\perl6\runtime\perl6-debug.moarvm:<main>:8)
from <unknown>:1 (C:\rakudo\share\perl6\runtime\perl6-debug.moarvm:<entry>:9)
or without debugger:
e:\src\prg\perl6>c:\rakudo\bin\perl6.bat -I. p6.p6
===SORRY!=== Error while compiling E:\src\prg\perl6\STD.pm6
Semicolon form of 'grammar' without 'unit' is illegal. You probably want to use 'unit grammar'
at E:\src\prg\perl6\STD.pm6:8
------> :ver<6.0.0.alpha>:auth<http://perl.org>;<HERE><EOL>
from p6.p6:2
STD.pm6 was the reference grammar/verifier maintained by Larry during the development of the various Perl 6 compilers (Rakudo, Pugs, Niecza, ...). It comes with a dedicated tool called viv that translates it to Perl 5. As far as I know, it never ran on any of the mainstream compilers.
With the 6.c language release, the torch of reference implementation has essentially passed on to Rakudo, which uses its own grammar written in NQP to parse Perl 6.
While this Grammar (in combination with the corresponding actions) can be used for manual parsing by importing these modules :from<NQP>, the more friendly approach (eg no need to declare $*LINEPOSCACHE) would be via the corresponding compiler object:
say nqp::getcomp('perl6').eval($source, :target<parse>).dump;
Other targets of interest might be :target<syntaxcheck> as well as the more low-level :target<ast> or for the curious perhaps even :target<mast>.
Working example from #perl6 conversation:
use nqp;
use Perl6::Grammar:from<NQP>;
use Perl6::Actions:from<NQP>;
my $source = q|say "hello world";|;
my $*LINEPOSCACHE;
my $p6c = Perl6::Grammar.parse($source, :actions(Perl6::Actions.new()));
say $p6c.dump

Idl readcol function, using delimeter without syntax error

Im trying to use idl to read a file, so im using the readcol command. However, in my file i use | as a delimiter, but continually get syntax errors. Heres my latest attempt:
readcol,'kcorrins.txt',uband, gband, rband, iband, zband, $
ubanderr, gbanerr, rbanderr, ibanderr, zbanderr, adjredshift, $
SKIPLINE=1, DELIMITER=|
could someone post an example of the proper syntax for using the delimiter in this way?
You need to quote the delimiter:
readcol,'kcorrins.txt',uband, gband, rband, iband, zband, $
ubanderr, gbanerr, rbanderr, ibanderr, zbanderr, adjredshift, $
SKIPLINE=1, DELIMITER='|'

Paamayim nekudotayims in PHP 5.2

I can upgrade php 5.2 in my server. I have to make this server work today (the vacation I have planned tomorrow is under question because of this error) with new testlink. I am stuck with following error i.e Paamayim nekudotayims.
What changes I should do to resolve it?
This link contains the file with the bug.
The Scope Resolution Operator (also called Paamayim Nekudotayim) or in simpler terms, the double colon, is a token that allows access to static, constant, and overridden properties or methods of a class.
SO may be in your codes you try to call static method or properties with wrong operator.
From Wikipedia:
In PHP, the scope resolution operator is also called Paamayim
Nekudotayim (Hebrew: פעמיים נקודתיים‎), which means “double colon” in
Hebrew.
The name "Paamayim Nekudotayim" was introduced in the
Israeli-developed Zend Engine 0.5 used in PHP 3. Although it has been
confusing to many developers who do not speak Hebrew, it is still
being used in PHP 5, as in this sample error message:
$ php -r :: Parse error: syntax error, unexpected
T_PAAMAYIM_NEKUDOTAYIM
As of PHP 5.4, error messages concerning the scope resolution operator
still include this name, but have clarified its meaning somewhat:
$ php -r :: Parse error: syntax error, unexpected '::'
(T_PAAMAYIM_NEKUDOTAYIM)

Resources