Apertium

Write an algorithm for finding cycles in a dependency tree

Write an algorithm to find cycles in a graph. CoNLL-U format looks like this, it is 10 columns.

# text = Hambali reportedly is cooperating to some degree.  
1  Hambali  _  _  _  _  4  _  _  _
2  reportedly  _  _  _  _  4  _  _  _
3  is  _  _  _  _  4  _  _  _
4  cooperating  _  _  _  _  0  _  _  _
5  to  _  _  _  _  7  _  _  _
6  some  _  _  _  _  7  _  _  _
7  degree  _  _  _  _  4  _  _  _
8  .  _  _  _  _  4  _  _  _

Ok, so : A dependency tree is a way of analysing a sentence. Each word is given a number/index, for example:

    I like writing cool algorithms
    1 2   3         4       5

This can be represented:

0 ROOT
1  I                  2
2  like              0
3  writing        2
4  cool             5
5  algorithms    3

             (0)
           ROOT
              |
          (2) like
         /          \
(1)  I          (3)  writing      
                              \ 
                               (5) algorithms
                                / 
                       (4) cool

Task tags

  • python
  • dependency
  • javascript
  • tree

Students who completed this task

Al Mao

Task type

  • code Code
close

2017