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

Support for JSON-LD data. #15

Open
y12studio opened this issue Apr 25, 2017 · 5 comments
Open

Support for JSON-LD data. #15

y12studio opened this issue Apr 25, 2017 · 5 comments

Comments

@y12studio
Copy link
Member

輸入參數與返回值支援JSON-LD格式定義的可行性?例如輸入工時表,輸出總工時統計或違法等JSON-LD定義的返回值。

it('月薪制勞工, 工時表(勞基法)', () => {
  let result = std.handle(JsonLdObj);
  expect(result.value).eq(JsonLdResult);
});

舉例 https://github.com/g0v/mydaka/blob/master/test/draft02.json

{
    "@context": "https://g0v.github.io/mydaka/contexts/v1.jsonld",
    "name": "Bob",
    "description": "CompanyA",
    "workingHours": ["Mo,Tu,We,Th 09:00-12:00", "Mo,Tu,We,Th 13:00-17:30"],
    "WorkingHoursSpec": [{
            "@type": "WorkingHoursSpec",
            "validFrom": "2013-12-24",
            "validThrough": "2013-12-25",
            "opens": "09:00",
            "closes": "11:00"
        },
        {
            "@type": "WorkingHoursSpec",
            "validFrom": "2014-01-01",
            "validThrough": "2014-01-01",
            "opens": "12:00",
            "closes": "14:00"
        }
    ]
}
@yurenju
Copy link
Collaborator

yurenju commented Apr 26, 2017

這看起來很不錯,我沒用過 JSON-LD,可以多舉一些例子嗎?比如說下面這個測試如果套用 JSON-LD 會需要做哪些修改?

        it('若「無」天災、事變或突發事件,但雇主要求於例假日工作並且徵得勞工同意時,此為違法加班' +
          '工資加倍發給。月薪制勞工,平均時薪 150 元並工作 2 小時,' +
          '加給工資 1200 元(勞基法 39, 40 條),並且無額外補休', () => {
          const accident = false;
          const consent = true;
          let result = std.overtimePay(150, 2, std.REGULAR_LEAVE, consent, accident);
          /*
          expect result looks like this:
          {
            status: std.ILLEGAL,
            value: 1200,
            extraLeave: {
              value: false
            },
            reference: [
              {
                id: 'LSA-39',
                description: '第三十六條所定之例假、休息日、第....',
                url: 'http://laws.mol.gov.tw/FLAW/FLAWDOC01.aspx?lsid=FL014930&flno=39'
              },
              { id: 'LSA-40' },
              { id: 'LSA-79' },
              { id: '台八十三勞動一字第 102498 號函' }
            ],
            fines: [
              { min: 20000, max: 1000000, according: 'LSA-79' }
            ]
          };
          */
          expect(result.value).eq(1200);
          expect(result.extraLeave.value).eq(false);
          expect(result.reference[0].id).eq('LSA-39');
          expect(result.reference[1].id).eq('LSA-40');
          expect(result.reference[2].id).eq('LSA-79');

          // https://laws.mol.gov.tw/FLAW/FLAWDOC03.aspx?datatype=etype&lc1=%5bc%5d%E5%8B%9E%E5%8B%95%E5%9F%BA%E6%BA%96%E6%B3%95%2c40&cnt=19&recordno=10
          expect(result.reference[3].id).eq('台八十三勞動一字第 102498 號函');
          expect(result.status).eq(std.ILLEGAL);

          // 79 條,罰則介於二萬到一百萬
          expect(result.fines[0].according).eq('LSA-79');
          expect(result.fines[0].min).eq(20000);
          expect(result.fines[0].max).eq(1000000);
        });

@yurenju
Copy link
Collaborator

yurenju commented Apr 26, 2017

所以如果是這個例子,在 reference array 裡面的每條法律會定義一個 schema,整個 JSON 會定義另外一個 schema 這樣對嗎?

@y12studio
Copy link
Member Author

@yurenju 沒有更多例子可提供因為mydaka專案已長草許久,概念分兩個方面講,一個是schema一個是JSON-LD。

schema

schema定義好後相關值的驗證可交給ajv負責,一些值就不需寫單元測試來驗。

ajv https://www.npmjs.com/package/ajv

JSON-LD

JSON-LD部分可用工具或google的結構化資料測試工具來檢驗,不過JSON-LD語義定義一直沒找到適用工時模型,後續如這個專案有興趣納入這類作法可移到這裡一起做,另外這裡的需求返回值還有法條語義模型待探索。

https://search.google.com/structured-data/testing-tool

Legislation : Proposed extension · Issue #1156 · schemaorg/schemaorg
schemaorg/schemaorg#1156

fireshot capture 922 - - https___search google com_structured-data_testing-tool

@yurenju
Copy link
Collaborator

yurenju commented Apr 26, 2017

@y12studio 這次 g0v 大松有要來嗎?可以見面討論一下

@yurenju
Copy link
Collaborator

yurenju commented Apr 26, 2017

另外目前的參與者都有在 g0v slack 裡面的 #labor 頻道,有興趣可以上來聊聊!

@yurenju yurenju mentioned this issue May 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants