skynav / ttt

Timed Text Toolkit
BSD 2-Clause "Simplified" License
75 stars 15 forks source link

allow to specify external semantic verifiers #156

Open samekmichal opened 9 years ago

samekmichal commented 9 years ago

Is it possible with the current implementation the specify custom (let's call it external) SemanticsVerifiers that would be "added" to the resource verification?

Say I have a scenario, where I have set limits for minimal and maximal duration of a cue. As this is not part of TTML sementics, it doesn`t make sense to modify the existing semantic verifiers.

I think that it could be implemented by...

What are your ideas on the above?

Thanks, Michal

skynavga commented 9 years ago

All of the ttv models except ttml1 derive from the ttml1 model or one of the other models that already derive from the ttml1 model; they merely override and extend the ttml1 model as required, sometimes by adding new constraints, sometimes by relaxing constraints;

In addition, after verification is complete the, if a ResultProcessor was supplied to:

TimedTextVerifier.run(List arguments, ResultProcessor resultProcessor)

then the ResultProcessor.processResults(...) method is invoked. This allows an external class to invoke TTV and supply a downstream processor that can perform additional processing steps. For example, this is used by TTX to perform transformation processing after verification, and TTXV is built on TTX in order to use the transformed results to perform additional verification steps.

I suppose we could add an additional command line to TTV that allows specifying a fully qualified class name that implements a ResultProcessor.

samekmichal commented 9 years ago

I suppose we could add an additional command line to TTV that allows specifying a fully qualified class name that implements a ResultProcessor.

And this external ResultProcessor (specified in command line argument) would get invoked after the built-in verification checks are passed. Do I get it right?

skynavga commented 9 years ago

Yes, that is the idea. This would basically be a built-in extensibility mechanism that allows one to external define such post-verification processing functionality without having to directly instantiate and invoke the TimedTextVerifier.run() method. It would attempt to resolve the specified class names using the classpath that applies to the command line invocation of TTV/TTX/TTPE.

Note that both TTX and TTPE supply a ResultProcessor instance to TTV. So if one wanted to override that ResultProcessor, it would be necessary to derive from the top-level TTX/TTPE classes and supply an @Override for processResults(...).

samekmichal commented 9 years ago

Still, wouldn't it be easier/more straightforward to implement it using SemanticsVerifier implementation? To see what I mean, check https://github.com/RBMHTechnology/ttt/commit/eb20b147dd2c2dcae903220fc2e05d2bb6283296

If you would use a ResultProcessor for that, you would have to implement all abstract methods ResultProcessor declares - which mostly take care of the command line arguments/configuration, which is IMHO not necessary for a domain-specific logic.