--
You received this message because you are subscribed to the Google Groups "ErgoAI, Flora-2, and XSB Users Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ErgoAI-Flora2-XSB...@coherentknowledge.com.
To view this discussion on the web visit https://groups.google.com/a/coherentknowledge.com/d/msgid/ErgoAI-Flora2-XSB-forum/9164cf28-d3f5-4fbb-b07e-60a06ddc4825n%40coherentknowledge.com.
Thank you for your prompt and helpful reply.
The iso8601 package has some very nice functionality. As a potential bug report, the following does not work on a XSB 4.0.0 (Ubuntu 20.04 LTS):
?- [iso8601].
?- date_string('YYYY-MM-DD',[Y,M,D],'2005-10-11').
I get an error "[Existence (No predicate iso8601 : date_string / 3 exists)]". Interestingly, the package is okay when recompiled separately. Am I missing something obvious?
Sincerely, Mark.
Thank you for your prompt and helpful reply.
The iso8601 package has some very nice functionality. As a potential bug report, the following does not work on a XSB 4.0.0 (Ubuntu 20.04 LTS):
?- [iso8601].
?- date_string('YYYY-MM-DD',[Y,M,D],'2005-10-11').
I get an error "[Existence (No predicate iso8601 : date_string / 3 exists)]". Interestingly, the package is okay when recompiled separately. Am I missing something obvious?
Sincerely, Mark.
It should be working now, if you pull and recompile xsb.
One thing is that it should be iso8601:date_string('YYYY-MM-DD',date(Y,M,D),'2005-10-11'), not a list, in arg 2.
I see that an earlier version tried to accommodate lists, but a
few days ago Teri took that option out.
--
--- michael
Thank you for this.
This now works: iso8601:date_string('YYYY-MM-DD',date(Y,M,D),'2005-10-11'), but iso8601:date_string('YYYY-MM-DD',date(2005,10,11),Date) gives an error "No predicate iso8601 : atom_codes / 2". I looked at the code but could not see the error.
Another question: what licence do you suggest for the xsb-timestamp package?
Sincerely, Mark.
Thank you for this.
This now works: iso8601:date_string('YYYY-MM-DD',date(Y,M,D),'2005-10-11'), but iso8601:date_string('YYYY-MM-DD',date(2005,10,11),Date) gives an error "No predicate iso8601 : atom_codes / 2". I looked at the code but could not see the error.
try again (after pulling)
Another question: what licence do you suggest for the xsb-timestamp package?
Better to use Apache2
--
--- michael
That now works. Thank you for the quick response.
I was going to change the XSB example at http://rosettacode.org/wiki/Merge_and_aggregate_datasets#Prolog, but the Git version is very new -- and the iso8601 package seems to use the same pattern as
number_datecodes(Number, [Y1,Y2,Y3,Y4,45,M1,M2,45,D1,D2]) :-
number_codes(Number, [Y1,Y2,Y3,Y4,M1,M2,D1,D2]).
which is crude but does provide a strict ordering for dates.
Sincerely, Mark.
Continuing the date theme, is there an example using add_cvt_type_hook/2 to read in a date from a CSV file? I tried:
The error is: "Permission (Operation) redefine on imported
predicate: proc_files : add_cvt_type_hook / 2".
Sincerely, Mark.
Nice - this works better than I expected, where the null date is
converted to an atom (with a warning 'Cannot convert to date:
""').
Thank you for your help with this.
-- Mark
Hi Mark,add_cvt_type_hook / 2 is a predicate that must be called to have an effect. You have given it a definition with a fact, which isn't accepted since the definition is already given by the import. I presume you want to execute that predicate. To do that you should change the line indicated as error to::- add_cvt_type_hook(date,date_converter(_,_)).
Which will cause it to be called when the file is loaded.(Actually, it is better form, I think, (even though I rarely use it) to write:?- add_cvt_type_hook(date,date_converter(_,_)).
)Thanks for your work on dates.-David
As a follow-up: is there a simple way to match on NaN values that
are input from a csv file? I have written an example using XSB at
http://rosettacode.org/wiki/Merge_and_aggregate_datasets#Prolog
that uses
is_nan(Number) :- number_codes(Number, [110,97,110|_]). %% "nan"
is_nan(Number) :- number_codes(Number, [78,97,78|_]). %% "NaN"
but that seems awkward and slow. Any other improvements on the code would also be welcome.
Sincerely, Mark.
Hi Mark,add_cvt_type_hook / 2 is a predicate that must be called to have an effect. You have given it a definition with a fact, which isn't accepted since the definition is already given by the import. I presume you want to execute that predicate. To do that you should change the line indicated as error to::- add_cvt_type_hook(date,date_converter(_,_)).
Which will cause it to be called when the file is loaded.(Actually, it is better form, I think, (even though I rarely use it) to write:?- add_cvt_type_hook(date,date_converter(_,_)).
)Thanks for your work on dates.-David
On Tue, Jun 1, 2021 at 9:36 AM Mark Clements (gmail) <samuel....@gmail.com> wrote:
Nice - the following seems to work.
is_nan(Number) :- X is Number, X =\= Number.
Kindly, Mark.
I certainly don't know much about NaN's, but I did try:
| ?- X is sqrt(-27.0), Y is X, X =:= Y.
no
| ?-
So this tries to take a NaN and compare it to itself to see if the comparison fails, under the assumption that they are the only values for which equality with themselves is false. The issue is how to get that copy, and it seems the is/2 does it. And you need to use a numeric comparison =:=.This hack seems to work here, but I have no idea how robust it is. I did note that:
| ?- X is 5.0/0.0, Y is X, X =:= Y.
X = inf.0
Y = inf.0
yes
| ?-which means it doesn't include inf's.
I hope this helps more than hurts.Best,David