jmrozanec / cron-utils

Cron utils for parsing, validations and human readable descriptions as well as date/time interoperability.
http://cron-utils.com
Apache License 2.0
1.15k stars 262 forks source link

Descriptions could be better #3

Open francisdb opened 9 years ago

francisdb commented 9 years ago

0 0 0 1 1 ? at 00:00 at 1 day at January month

0/1 * * * * ? every seconds

https://github.com/RedHogs/cron-parser seems to be doing a way better job...

jmrozanec commented 9 years ago

Yes, we need to improve this. More examples would be useful, so that we can use them for tests and improve current descriptions. Thanks!

francisdb commented 9 years ago

Their tests contain all needed examples: https://github.com/RedHogs/cron-parser/blob/master/src/test/java/net/redhogs/cronparser/CronExpressionDescriptorTest.java (also other languages available)

Naxos84 commented 7 years ago
public class TestDescriptor {

    // SoM MoH HoD D0M MoY  DoW Year
    // 3/4 5/6 7/8 9/2 10/2 ?   2017/2

    //expected result (separated in lines) (taken from https://www.freeformatter.com/cron-expression-generator-quartz.html)
    //Every 4 seconds starting at second 03,
    //every 6 minutes starting at minute :05,
    //every 8 hours starting at 07am,
    //every 2 days starting on the 9th,
    //every 2 months starting in October,
    //every 2 years starting in 2017
    @Test
    public void testFull() {
        final CronDefinition cronDefinition = CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ);
        final CronParser parser = new CronParser(cronDefinition);
        final Cron cron = parser.parse("3/4 5/6 7/8 9/2 10/2 ? 2017/2");
        System.out.println(CronDescriptor.instance().describe(cron));
    }

}

This gives: every 4 seconds every 6 minutes every 8 hours every 2 days every February months every 2 year After fixing a formatting issue during runtime. see #300

Therefore I'm currently working on a big bunch of tests to cover a lot of description examples.

jmrozanec commented 6 years ago

@francisdb @Naxos84 we are getting back to this issue - this time would like to explore using some machine learning to achieve the goal. We would take current English descriptions as the original text to be translated by a deep learning model into a better human-readable text, which may be in English or another language. For this we should:

Experiments would be run for English translations first. If we succeed at this, will continue developing with the same approach for other languages as well. We would like to target the problem using some machine learning since it is difficult to provide good human-readable descriptions for languages in general just with a properties pattern since structure and terms used vary from language to language.

Ideas and suggestions are always welcome!

Naxos84 commented 6 years ago

@jmrozanec I don't have any experience in machine learning. But this sound interesting and therefore we should give it a try. :)

jmrozanec commented 6 years ago

@Naxos84 Great! We have been experimenting with Neural Machine Translation with good results up to now. Soon will be posting code we used to generate training samples and will request some help to generate new patterns so that we cover a wider range of cases. Thanks!

jmrozanec commented 6 years ago

We would like to invite everyone to contribute to this repo with expression generators for different languages so that we can later create datasets and train models which would provide accurate descriptions for each case.

francisdb commented 6 years ago

Can we not just do something like what these guys do, the NL/FR/EN results are great according to their tests https://github.com/grahamar/cron-parser/tree/master/cron-parser-core/src/test/java/net/redhogs/cronparser

jmrozanec commented 6 years ago

@francisdb Thank you for pointing that out! I think they do a very good job when it comes to NL/FR/EN, but I am not so sure we can fit good descriptions for all languages to those templates. By using a neural translation approach we may ensure very good quality regardless of the complexities of any language.

Naxos84 commented 6 years ago

I know that the machine learning project has started. I also tried to have a look into it. But I'm not sure how to correctly contribute to it. Could you please (again) provide info on how to do this.

jmrozanec commented 6 years ago

@Naxos84 thank you for reaching out! We are tackling the issue from several poins:

Neural translation model worked very well for English-English - we would like to expand this to other languages as well. The python code will most likely remain the same. The hard work to be done is consider exhaustive cases to provide translations to several languages and then how can we

Please let us know if anything else shall be clarified! :smile: Thanks!

toughpheeckouse commented 6 years ago

if I correctly understood it is about plural forms and transaltion. This task is very cleverly implemented in GWT.

Please take a look at PluralRule and implementation for many locales

jmrozanec commented 6 years ago

@toughpheeckouse thanks! We will take a look at it!

natrajmolala commented 5 years ago

There is an addition to this. Cron Expression is Wrong when used astertic at Second place. Example : 0 9-23 * ? Description : every hour between 9 and 23

Expected Description : Every second, at minute :00 every hour between 09am and 23pm, of every day This is taken from https://www.freeformatter.com/cron-expression-generator-quartz.html. And this is giving right info

jmrozanec commented 5 years ago

@natrajmolala thank you for reporting this. You are welcome to send a PR with a test for this. Best! :smile:

natrajmolala commented 5 years ago

@jmrozanec The test is in place and in a local branch. I think you need to add me to contributors list so I can raise PR?

jmrozanec commented 5 years ago

@natrajmolala not necessary - anyone can issue a PR, regardless his project status :)