Skip to content

Instantly share code, notes, and snippets.

@kowey
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kowey/9804330 to your computer and use it in GitHub Desktop.
Save kowey/9804330 to your computer and use it in GitHub Desktop.

Starting dependency tree

     e2
attr / \ purpose
    /   \
   e1   e4
        /\
  attr /  \ comment
      e3  e5

Ambiguities:

  • e4 -> e3 or e4 -> e5 first
  • e2 -> e1 or e2 -> e4 first?

Scenario A (e3, e4)

  1. First e4 -attr-> e3

        e2
       /  \
      e1  +----------+
          |   attr   |
          | S /  \ N |
          | e3   e4  |
          +----------+
              \
              e5
    
  2. Then e4 -comment-> e5

       e2
      /  \
     e1  +-------------+
         |    comment  |
         |   N /   \ S |
         |    /     \  |
         | e3..e4   e5 |
         +-------------+
    
  3. Then e2 -purpose-> e4

         +--------------+
         |    purpose   |
         |  N /   \ S   |
         |   /     \    |
       / |  e2   e3..e5 |
      e1 +--------------+
    
  4. Finally, e2 -attr-> e1

         +--------------+
         |    attr      |
         |  S /   \ N   |
         |   /     \    |
         |  e1   e2..e5 |
         +--------------+
    

So far so good, but were we just lucky?

Scenario B (e3, e1)

  1. Backing up to the result of step 2 above

        e2
       / \
      /   \
     e1  +------+
         |e3..e5|
         +------+
    
  2. Now this time, we swing left first (e2 -attr-> e1):

     +--------------+
     |    attr      |
     |  S  /\ N     |
     |    /  \      |
     |  e1    e2    |
     +--------------+
              \
               \
              +------+
              |e3..e5|
              +------+
    
  3. And then do the e2 - purpose -> e4 link

     +----------------+
     |    purpose     |
     |   N  /\ S      |
     |     /  \       |
     |    /    \      |
     |  e1..e2 e3..e5 |
     +----------------+
    

So that worked out reasonably well too. Maybe we're OK so long as we don't have crossing dependencies. I seem to remember that I could blow up the converter just by changing the order I processed the nodes in these ambiguous cases though; will have to revisit next week

(maybe when there are 3 links, there's a way you can process them such that you create a crossing dependency and thereby be stuck in terms of how to build the RST tree, maybe I misremember)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment