Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

40
LINES

< > BotCompany Repo | #1028543 // test_EnglishDateParser (OK)

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (8479L/48K).

svoid test_EnglishDateParser() {
  new EnglishDateParser parser;
  parser.assumeFuture = true; // maybe not needed
  testFunctionValues(s -> parser.parse((S) s), mapToParams(test_EnglishDateParser_examples()));
}

static Map<S, DateStructures.SomeDate> test_EnglishDateParser_examples() {
  delegate Day to DateStructures.
  delegate Month to DateStructures.
  delegate Year to DateStructures.
  delegate CurrentWeekPlus to DateStructures.
  delegate Weekday to DateStructures.
  delegate TodayPlus to DateStructures.
  delegate Hour to DateStructures.
  delegate Minute to DateStructures.
  delegate Second to DateStructures.
  delegate Between to DateStructures.

  ret litorderedmap(
    "2020/5/13" := new Day(13, new Month(5, new Year(2020))),
    "tuesday" := new Weekday(3, null),
    "next tuesday" := new Weekday(3, new CurrentWeekPlus(1)),
    "in 5 days" := new TodayPlus(5),
    "10 days from now" := new TodayPlus(10),
    "February" := new Month(2),
    "February 2020" := new Month(2, new Year(2020)),
    "March 4th" := new Day(4, new Month(3)),
    "yesterday" := new TodayPlus(-1),
    "today" := new TodayPlus(0),
    "tomorrow" := new TodayPlus(1),
    
    "15:43" := new Minute(43, new Hour(3, true)),
    "10:41" := new Minute(41, new Hour(10, null)),
    "3 am" := new Hour(3, false),
    "5 pm" := new Hour(5, true),
    "16:41:23" := new Second(23, new Minute(41, new Hour(4, true))),
    
    "between 1 and 2 pm" := new Between(new Hour(1, true), new Hour(2, true)),
  );
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028543
Snippet name: test_EnglishDateParser (OK)
Eternal ID of this version: #1028543/30
Text MD5: 53519b5bea7034e10bbc60daf1263cdf
Transpilation MD5: 9bdbce763d16d814fc79d1b0fb25364c
Author: stefan
Category: javax / english nlp
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-15 00:32:34
Source code size: 1540 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 279 / 555
Version history: 29 change(s)
Referenced in: [show references]