通过java访问Prolog谓词

时间:2018-04-13 19:57:26

标签: java prolog swi-prolog

执行代码时出错。

sgn(...)

,错误是

  

线程中的异常" main" java.lang.ClassCastException:java.util.HashMap无法强制转换为java.util.Hashtable       在newProj.MyMain.main(MyMain.java:18)

Prolog Predicates

from pandas.tseries.offsets import *


light1 = pd.read_csv('G:/light1.csv')

light1.Time = pd.to_datetime(light1.Time)

tdelta = datetime.timedelta(hours=5)
time_before_5_hours  = light1.Time + tdelta
#rng = pd.date_range(start=light1.Time, end=time_before_5_hours,periods=1, freq='m' )
s = light1.Time
m= light1.Time - DateOffset(hours = 5)


from dateutil import rrule
import datetime
def hours_between(start_date, end_date):
    time = rrule.rrule(rrule.MINUTELY, dtstart=s, until=m)
    return hours_between
with open('G:/project/light1.csv') as input_file:
    with open('G:/light2.csv', 'w') as csvoutput:
        writer = csv.writer(csvoutput, lineterminator='\n')
        reader = csv.reader(input_file)

        all = [ ]
        row = next(reader)
        row.append('k')
        all.append(row)

        for row[0] in csv.reader(input_file):
            try:
                v = hours_between(input_file.Time,input_file.Time - DateOffset(hours = 5))
                if v.bool() == True :
                    row.append(1)
                    all.append(row)
                    writer.writerows(all)
                    row = next(reader)
                else:
                    row.append(0)
                    all.append(row)
            writer.writerows(all)

1 个答案:

答案 0 :(得分:0)

试试这个

    Query q =new Query("parent("ali",X)")

    java.util.Hashtable solution;

    while ( q.hasMoreSolutions() ){
        solution = q.nextSolution();
        System.out.println( "X = " + solution.get(X));
    }