cron-utils icon indicating copy to clipboard operation
cron-utils copied to clipboard

Descriptions could be better

Open francisdb opened this issue 10 years ago • 17 comments

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...

francisdb avatar Dec 19 '14 15:12 francisdb

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

jmrozanec avatar Dec 27 '14 12:12 jmrozanec

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)

francisdb avatar Dec 27 '14 13:12 francisdb

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.

Naxos84 avatar Dec 06 '17 08:12 Naxos84

@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:

  • develop a dataset, with current descriptions and desired matches. Best way to do it would be to get a diverse range of patterns and randomly alter descriptions, to cover a wide range of variations.
  • develop a deep learning model: as a start, we can develop it with Keras and load it with dl4j

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!

jmrozanec avatar Mar 24 '18 19:03 jmrozanec

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

Naxos84 avatar Mar 26 '18 05:03 Naxos84

@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 avatar Mar 26 '18 12:03 jmrozanec

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.

jmrozanec avatar Jul 03 '18 01:07 jmrozanec

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

francisdb avatar Jul 03 '18 12:07 francisdb

@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.

jmrozanec avatar Jul 03 '18 13:07 jmrozanec

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.

Naxos84 avatar Aug 02 '18 06:08 Naxos84

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

  • build datasets, that will provide patterns and desired translations. We created a repo to add dataset generators for supported languages. We aim to translate from current english descriptions provided by cron-utils to the ideal ones. Up to now we just created a generator for English expressions.
  • train models that will perform the translations. We created a repo to track the algorithms we use to achieve it and the models we build. The model that worked best is a char-by-char neural translation. We tested it for English-English. The model was built using python and is serialized into .h5. We are still figuring out how to serialize from python and deserialize in Java :smile:
  • create a satellite repo, that would provide means to download and load the models we trained in order to provide better descriptions when additioned to the core.

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

  • store and version the models we train in order to be accessible on the web
  • how we load them within the satellite repo, so that can be used from the JVM.

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

jmrozanec avatar Aug 06 '18 12:08 jmrozanec

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

toughpheeckouse avatar Sep 22 '18 20:09 toughpheeckouse

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

jmrozanec avatar Sep 23 '18 07:09 jmrozanec

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

natrajmolala avatar Mar 12 '19 11:03 natrajmolala

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

jmrozanec avatar Mar 12 '19 11:03 jmrozanec

@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?

natrajmolala avatar Mar 12 '19 15:03 natrajmolala

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

jmrozanec avatar Mar 12 '19 19:03 jmrozanec