retextjs / retext

natural language processor powered by plugins part of the @unifiedjs collective
https://unifiedjs.com
MIT License
2.36k stars 93 forks source link

direction demo does not behave correctly #15

Closed rbakhshi closed 10 years ago

rbakhshi commented 10 years ago

the demo (http://wooorm.github.io/retext-directionality/) tries to show how bidi text can be detected and handled by retext. The line with both Hebrew and English should be right to left as it starts with Hebrew.

wooorm commented 10 years ago

To be honest, directionality only really color codes grammatical units, and if a unit is completely LTR or RTL, sets that value as the DOM node’s dir attribute. Thus, a bidirectional paragraph is not marked with any actual dir (although its sentences might).

You say the direction of the first sentence (the first child) should be applied to paragraph (the parent):

  1. Should this still apply if the paragraph starts with one Hebrew sentence, and follows with two in English (and what about 5 in English, or more)?
  2. What about an initial English sentence, followed by multiple in Hebrew?
  3. Do you know of any resources on this?

Regarding 1. and 2., if I add [dir="rtl"] to an ancestor (such as body or .directionality__output), the paragraph shows up as you recommended.

In fact, I’m not sure I as a plugin developer should choose a ratio to apply neutral, LTR, or RTL directionality. Maybe it’s best to let users find that out on their own: such as, when a RootNode is classified as "neutral", detect which direction is used more than the other and apply that to a DOM node?

wooorm commented 10 years ago

Did that help? Can I close this issue?

rbakhshi commented 10 years ago

Yup. Thanks. Feel free to close it On 12/08/2014 9:52 PM, "Titus" notifications@github.com wrote:

Did that help? Can I close this issue?

— Reply to this email directly or view it on GitHub https://github.com/wooorm/retext/issues/15#issuecomment-51906575.

wooorm commented 10 years ago

Cool! Let me know if you have any other questions! :smile: