Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

「729全台大停電」這一則會掛在 Building Dates #93

Open
pm5 opened this issue Nov 25, 2013 · 4 comments
Open

「729全台大停電」這一則會掛在 Building Dates #93

pm5 opened this issue Nov 25, 2013 · 4 comments
Labels

Comments

@pm5
Copy link
Member

pm5 commented Nov 25, 2013

http://fact.g0v.tw/wiki/729%E5%85%A8%E5%8F%B0%E5%A4%A7%E5%81%9C%E9%9B%BB

記錄一下。

@jimyhuang
Copy link
Member

喔,新的date parser改了之後,parse不到這裡的日期 XD
http://fact.g0v.tw/wiki/.json?nocache=1

@taichunmin
Copy link
Contributor

不知道這個東西有沒有幫助,
剛剛很努力的去看了 lib/zhdateparser.js 沒有看很懂
順手寫了一個正規表示法
但是不知道怎麼套進去xd

https://www.debuggex.com/r/Z92q2SWxSwDavGxD
Debuggex

我這個正規表達式會很聰明的把 日期 的各部份切開

Group 0: 全部的年份文字
Group 1: 西元 民國 或 undefined
Group 2: 前 或 undefined
Group 3: 年份,會自動抓年後面的一個非數字,例如年代、年底之類的
Group 4: 月份,會自動抓月後面的一個非數字,例如月初、月底之類的
Group 5: 日期

@jimyhuang
Copy link
Member

@taichunmin 太好了..
找出年份,是在 https://github.com/g0v/twangry/blob/master/lib/zhdateparser.js#L132

而這是截出整段的 https://github.com/g0v/twangry/blob/master/lib/zhdateparser.js#L137

  // Real parser
  // Phase 1: Find summary start at year, end with specific html tag
  pattern = /(<a[^>]+>)?(西元)?([1-2][0-9]{3}年?)?(-|-|~|~)?([1-2]?[0-9]{3}(<\/[^>]+>)?(年代|年|底)(<\/[^>]+>)?([0-9]{1,2}月(<\/[^>]+>)?|)([0-9]{1,2}日|)).+(<\/(li|p|div|ul)>)/g;

要不要直接pull request?

@taichunmin
Copy link
Contributor

目前還沒有比較明確的想法xd
而且我也還不知道 到底問題是出在哪邊
繼續研究看看 哈
@jimyhuang 辛苦啦xd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants