gpt4 book ai didi

Java SimpleDateFormat 将问题解析为 WEKA

转载 作者:行者123 更新时间:2023-12-02 08:19:44 25 4
gpt4 key购买 nike

我发誓我使用了正确的日期格式,但在加载到 WEKA 时我不断收到解析错误。

"MonFeb2116:00:00+0000"
"EEEMMMddHH:mm:ssZ"

这是一个示例数据集:

@RELATION example

@ATTRIBUTE tweetid STRING
@ATTRIBUTE timestamp DATE "EEEMMMddhh:mm:ssZ"
@ATTRIBUTE I NUMERIC
@ATTRIBUTE a NUMERIC
@ATTRIBUTE cool NUMERIC
@ATTRIBUTE foo NUMERIC
@ATTRIBUTE bar NUMERIC
@ATTRIBUTE temp NUMERIC
@ATTRIBUTE class {POS,NEG}

@DATA
39715973388828673,"MonFeb2116:00:00+0000",0,0,0,0,2,2,?
39716148329197568,"MonFeb2116:00:42+0000",0,1,0,0,0,1,?
39715973388828673,"MonFeb2116:00:51+0000",1,0,0,0,0,0,?
39723030380941312,"MonFeb2116:28:03+0000",0,0,0,0,0,0,?
39723030531944448,"MonFeb2116:28:03+0000",0,0,0,0,0,0,?
39723031433707520,"MonFeb2116:28:03+0000",0,0,0,0,0,0,?

WEKA 错误:

unparseable date "MonFeb2116:00:00+0000, read Token[MonFeb2116:00:00+0000], line 21

是否已使用 API 文档进行了双重检查 - 遗漏了某些内容?

http://download.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html

编辑 -----------

@RELATION example

@ATTRIBUTE tweetid STRING
@ATTRIBUTE timestamp DATE "EEE MMM dd hh:mm:ss Z"
@ATTRIBUTE I NUMERIC
@ATTRIBUTE a NUMERIC
@ATTRIBUTE cool NUMERIC
@ATTRIBUTE foo NUMERIC
@ATTRIBUTE love NUMERIC
@ATTRIBUTE temp NUMERIC
@ATTRIBUTE class {POS,NEG}

@DATA
39715973388828673,"Mon Feb 21 16:00:00 +0000",0,0,0,0,2,2,?
39716148329197568,"Mon Feb 21 16:00:42 +0000",0,1,0,0,0,1,?
39715973388828673,"Mon Feb 21 16:00:51 +0000",1,0,0,0,0,0,?
39723030380941312,"Mon Feb 21 16:28:03 +0000",0,0,0,0,0,0,?
39723030531944448,"Mon Feb 21 16:28:03 +0000",0,0,0,0,0,0,?
39723031433707520,"Mon Feb 21 16:28:03 +0000",0,0,0,0,0,0,?

格式化日期以用空格分隔标记。还没在WEKA打球...

最佳答案

您使用的是哪个默认区域设置?使用英语区域设置时,字符串 "MonFeb2116:00:00+0000" 应可使用模式 "EEEMMMddHH:mm:ssZ" 进行解析。但请注意,如果模式或解析的字符串中不存在年份,则年份将默认为 1970 年。这可能不是您真正想要的。

关于Java SimpleDateFormat 将问题解析为 WEKA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5704125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com