Most modern editions don't distinguish vocalic I from consonantal J. Most of the time, this doesn't create any real ambiguity.
However, for certain purposes it can be useful to know the difference: for example, when reading a passage out loud, or for composing metered poetry.
If I have a text that marks everything except I vs J, what's the best way to automatically determine the difference? My goal is a program that can go through and mark Js without human intervention—so it doesn't matter how complicated that system is, so long as it doesn't require specific human knowledge (so Asteroides's otherwise-excellent suggestion to look at English derivatives doesn't help me).
For a definite example: how can I know that Jūlius and Troja have a J, but Iūlus and Gāius have an I? Is there a reliable dictionary that lists this, for example, even in the case of proper names? Or is the best option to implement Alex B's general rules and not worry about the occasional error in a Greek loan?
(Bonus points if this can also recognize "hidden" Js before
/i/, as in ejiciō.)