gnu-prolog - initialization predicate failing - command-line
In compiling and running the code below (pl_check_input.pl), I get "user directive failed" on the ":- initialization..." line
:- dynamic(doit/0).
:- initialization(doit).
:- include(head).
doit :-
readFB(user_input),
writeFB,
halt.
:- include(tail).
$ gplc --no-del-temp --no-top-level pl_check_input.pl
$ ./pl_check_input <fb1 >fb2
warning: /home/tarvydas/Dropbox/Projects/vsh/pl-vsh/pl_check_input.pl:2: user directive failed
If I remove the offending line
:- dynamic(doit/0).
:- include(head).
doit :-
readFB(user_input),
writeFB,
halt.
:- include(tail).
$ gplc --no-del-temp --no-top-level pl_check_input.pl
$ ./pl_check_input <fb1 >fb2
Warning: no initial goal executed
use a directive :- initialization(Goal)
or remove the link option --no-top-level (or --min-bips or --min-size)
Any insights would be very welcome.
Ultimately, I have this code running from the REPL, but I want to put it in a linux pipeline script and remove the various banner lines that come with top-level/0.
"never mind", it turned out to be a missing rule that generated a very misleading error message. To duplicate the error, create junk.pl:
:- initialization(main).
:- include(head).
main :-
readFB(user_input),
writeFB,
halt.
:- include(tail).
and create file head.pl:
:- dynamic(component/1) .
:- dynamic(edge/1) .
create file tail.pl (the first commented out line is the missing rule)
% writeterm(Term) :- current_output(Out), write_term(Out, Term, []), write(Out, '.'), nl.
writeFB :-
forall(component(X), writeterm(component(X))),
forall(edge(X), writeterm(edge(X))).
readFB(Str) :-
read_term(Str,T0,[]),
element(T0,Str).
element(end_of_file, _) :- !.
element(component(X), Str) :- !,
asserta(component(X)),
readFB(Str).
element(edge(X), Str) :- !,
asserta(edge(X)),
readFB(Str).
create file fb1a:
component('pl_vsh') .
edge(e0) .
then run a compile and execute the command:
$ gplc junk.pl --no-top-level
$ ./junk <fb1a >fb2
which results in the error message:
warning: /home/xxx/xxx/xxx/xxx/xxx/junk.pl:1: user directive failed
Related
object not found when creating targets list programmatically
I'm trying to generate a {targets} list programmatically, via a function in an R package. get_pipeline <- function(which_countries) { countries <- NULL # avoid R CMD CHECK warning print(which_countries) # Shows that which_countries is available list( targets::tar_target( name = countries, command = which_countries # But here, which_countries is not found ) ) } The _targets.R file looks like this: library(targets) couns <- c("USA", "GBR") TargetsQuestions::get_pipeline(couns) I see the following error: > tar_make() [1] "USA" "GBR" Error in enexpr(expr) : object 'which_countries' not found Error in `tar_throw_run()`: ! callr subprocess failed: object 'which_countries' not found Note that the which_countries variable is printable, but not found in the call to tar_target. How can I get create the countries target successfully so that it contains the vector c("USA", "GBR")? This code is in a GitHub repository at https://github.com/MatthewHeun/TargetsQuestions. To reproduce: git clone https://github.com/MatthewHeun/TargetsQuestions Build the package in RStudio. targets::tar_make() at the Console. Thanks in advance for any suggestions!
Thanks to #landau for pointing to https://wlandau.github.io/targetopia/contributing.html#target-factories which in turn points to the metaprogramming section of Advanced R at https://adv-r.hadley.nz/metaprogramming.html. The solution turned out to be: get_pipeline <- function(which_countries) { list( targets::tar_target_raw( name = "countries", # command = which_countries # which_countries must have length 1 # command = !!which_countries # invalid argument type command = rlang::enexpr(which_countries) # Works ) ) } With _targets.R like this: library(targets) couns <- c("USA", "GBR") TargetsQuestions::get_pipeline(couns) the commands tar_make() and tar_read(countries), give [1] "USA" "GBR" as expected!
Bad substitution using sh
I have the following script and I'm getting the following error: Error: Bad substitution value="$(cat temp.txt)" valueWOBegin="$(echo ${value/*====BUILDTYPES====/})" valueWOEnd="$(echo ${valueWOBegin/====END BUILDTYPES====*/})" This is the temp.txt file ====BUILDTYPES==== [BuildType_Decorated{name=debug, debuggable=true, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, minifyEnabled=false, zipAlignEnabled=true, signingConfig=SigningConfig_Decorated{name=debug, storeFile=/mypath/debug.keystore, storePassword=android, keyAlias=AndroidDebugKey, keyPassword=android, storeType=jks, v1SigningEnabled=true, v2SigningEnabled=true, v1SigningConfigured=false, v2SigningConfigured=false}, embedMicroApp=false, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}}, BuildType_Decorated{name=release, debuggable=false, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, minifyEnabled=true, zipAlignEnabled=true, signingConfig=null, embedMicroApp=true, mBuildConfigFields={}, mResValues={}, mProguardFiles=[/mypath/proguard-rules.pro], mConsumerProguardFiles=[], mManifestPlaceholders={}}] ====END BUILDTYPES====
LB 4.1: uid is not installed
I am trying to use the unique id as described in the Reference Manual. However, I get the following error: Error: P2PMapping defined at block_1Z1C1O1V:4(2)--7(73) requests module 'uid', but no module with that name is installed. How do I install this module?
What is your program, exactly? I just tried the following lb script (which is a simplified version of the example from the manual): create --unique addblock <doc> F[x] = id -> string(x), int(id). R(x) -> string(x). R("Joe"). R("Jill"). </doc> exec <doc> +F[x] = id <- uid<<id>> R(x). </doc> print F close --destroy The result is, as expected: created workspace 'unique_workspace_2016-11-20-21-12-30' added block 'block_1Z1B38XS' "Jill" 10000000044 "Joe" 10000000046 deleted workspace 'unique_workspace_2016-11-20-21-12-30'
Annotating a corpus using Syntaxnet
I am trying to annotate a corpus using Syntaxnet. I added the following lines in the end of the /models/syntaxnet/syntaxnet/models/parsey_mcparseface/context.pbtxt file: input { name: 'input_file' record_format: 'english-text' Part { file_pattern: '/home/melvyn/text.txt' } } output { name: 'output_file' record_format: 'english-text' Part { file_pattern: '/home/melvyn/text-tagged.txt' } } When i run the command: ./demo.sh --input=input_file --output=output_file I am getting: ./demo.sh: line 31: bazel-bin/syntaxnet/parser_eval: No such file or directory ./demo.sh: line 43: bazel-bin/syntaxnet/parser_eval: No such file or directory ./demo.sh: line 55: bazel-bin/syntaxnet/conll2tree: No such file or directory According to the answer given ## here ## I changed my demo.sh file and now I get some errors which say: [libprotobuf ERROR external/tf/google/protobuf/src/google/protobuf/text_format.cc:291] Error parsing text-format syntaxnet.TaskSpec: 200:8: Message type "syntaxnet.TaskOutput" has no field named "Part". E external/tf/tensorflow/core/framework/op_segment.cc:53] Create kernel failed: Invalid argument: Could not parse task context at syntaxnet/models/parsey_mcparseface/context.pbtxt E external/tf/tensorflow/core/common_runtime/executor.cc:333] Executor failed to create kernel. Invalid argument: Could not parse task context at syntaxnet/models/parsey_mcparseface/context.pbtxt [[Node: DocumentSource = DocumentSourcebatch_size=32, corpus_name="stdin-conll", task_context="syntaxnet/models/parsey_mcparseface/context.pbtxt", _device="/job:localhost/replica:0/task:0/cpu:0"]] What could be a possible solution?
Though it's not certain but I think you are not running the shell script from the root directory. Please try running it as per the instructions mentioned here I hope it helps.
Erlang and PostgreSQL
I try to execute simple PostgreSQL query with erlang and epgsql. I do: {ok, C} = pgsql:connect("localhost", "shk", "qwerty", [{database, "mydb"}]). >> {ok,<0.34.0>} Then: {ok, Cols, Rows} = pgsql:squery(C, "select * from users"). But i got error: =ERROR REPORT==== 27-Apr-2012::17:58:23 === ** State machine <0.34.0> terminating ** Last message in was {'EXIT',<0.32.0>, {{badmatch, {error, {error,'ð\236ð¨ð\230ð\221ð\232ð\220',<<"42P01">>, <<208,190,209,130,208,189,208,190,209,136,208,181, 208,189,208,184,208,181,32,34,109,121,100,98,34, 32,208,189,208,181,32,209,129,209,131,209,137, 208,181,209,129,209,130,208,178,209,131,208,181, 209,130>>, [{position,<<"15">>}]}}}, [{erl_eval,expr,3}]}} ** When State == ready ** Data == {state,undefined,<0.35.0>,5000, [{<<"application_name">>,<<>>}, {<<"client_encoding">>,<<"UTF8">>}, {<<"DateStyle">>,<<"ISO, DMY">>}, {<<"integer_datetimes">>,<<"on">>}, {<<"IntervalStyle">>,<<"postgres">>}, {<<"is_superuser">>,<<"off">>}, {<<"server_encoding">>,<<"UTF8">>}, {<<"server_version">>,<<"9.0.7">>}, {<<"session_authorization">>,<<"shk">>}, {<<"standard_conforming_strings">>,<<"off">>}, {<<"TimeZone">>,<<"posixrules">>}], undefined,undefined,undefined, {30932,488494147}, {statement,undefined,undefined,undefined}, 73} ** Reason for termination = ** {{badmatch,{error,{error,'ð\236ð¨ð\230ð\221ð\232ð\220',<<"42P01">>, <<208,190,209,130,208,189,208,190,209,136,208,181, 208,189,208,184,208,181,32,34,109,121,100,98,34, 32,208,189,208,181,32,209,129,209,131,209,137, 208,181,209,129,209,130,208,178,209,131,208,181, 209,130>>, [{position,<<"15">>}]}}}, [{erl_eval,expr,3}]} What's wrong i do? How can i fix it? Thank you.
The error string seems to be in russian if I recognize the characters. To view the response you can use the following command: io:format("~ts",[<<208,190,209,130,208,189,208,190,209,136,208,181, 208,189,208,184,208,181,32,34,109,121,100,98,34, 32,208,189,208,181,32,209,129,209,131,209,137, 208,181,209,129,209,130,208,178,209,131,208,181, 209,130>>]). отношение "mydb" не существует A quick google translate makes me think the database mydb does not exist or you do not have permissions to use it.
try simply doing Response = pgsql:squery(C, "select * from mydb"), io:format("~p~n",[Response]). And see what he is giving back from the server, maybe you have typo or table don't exists etc. also check this out http://www.erlangatwork.com/2009/01/erlang-and-postgresql.html
From epgsql docs: Errors Errors originating from the PostgreSQL backend are returned as {error, #error{}}, see pgsql.hrl for the record definition. epgsql functions may also return {error, What} where What is one of the following: {unsupported_auth_method, Method} - required auth method is unsupported timeout - request timed out closed - connection was closed sync_required - error occured and pgsql:sync must be called Try to include pgsql.hrl, capture the error and print the error message, that should point you to the right direction.