Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is two questions, one regarding identification, the other conversion. </p> <p>Identification of possible date context is (relatively) easy, conversion is however deeply problematic for a number of reasons, notably the sheer variety of ways one can semantically express a date, and the concomitant ambiguities and misrepresentations which can emerge. Let's look at some obvious pitfalls here:</p> <ul> <li><p>"The day after tomorrow 2pm." If we simply evaluate on "tomorrow 2pm" we are going to be a day adrift.</p></li> <li><p>"Two days after 16.10.2010".. It gets worse...</p></li> <li><p>"not much before 9pm Friday 13th March 2013" We can get the date back but the context renders it very ambiguous.</p></li> </ul> <p>Assuming you only want to identify a potential date match in a String you could do something like this...</p> <pre><code>private final String[] datePatterns = {"Yesterday","Today","Tomorrow", //etc "Sunday","Monday","Tuesday","Thursday","Friday", // etc "Lundi","Mardi","Mercredi", //etc in French "2001","2002", // all the years "AM","PM", "January","February","March","August"}; private List lx = new ArrayList(); public boolean mayContainDates(String toCheck) { toCheck = toCheck.toUpperCase(); // irl we'd build this list 1 time in the constructor for(int i = 0; i &lt; datePatterns.length; i++) { lx.add(datePatterns[i].toUpperCase()); } Iterator lit = lx.iterator(); while(lit.hasNext()) { if (toCheck.contains((String) lit.next()) { return true; } } return false; } </code></pre> <p>It's really a question of how you set up your datePattern String array of comparators. Alternatively you could iterate an array of regexps in a somewhat similar fashion but it would be slow. You'll probably get a lot of false positives but you can obviously improve on this simple model.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload