CoNLL-U major mode for emacs
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
static
.gitignore
LICENSE
README
conllu-align.el
conllu-edit.el
conllu-flycheck.el
conllu-mode.el
conllu-move.el
conllu-parse.el
conllu-thing.el

README

emacs mode for CoNLL-U files

https://melpa.org/packages/conllu-mode-badge.svg

this mode provides simple utilities for editing and viewing CoNLL-U files.

you can watch the following demo for an idea of what it can do:

static/demo.png

default key bindings

key bindingdescription
C-c C-eedit token line at point interactively using a hydra
C-c C-aalign columns (inserts no real whitespace) in the selected region (defaults to the current sentence)
C-c C-uunalign columns in the selected region (defaults to current sentence)
C-c C-hmove point to head token of present token
C-c C-cclear field at point, placing _ as its value
C-c C-linsert empty token line at point or at next line (can be called with prefix argument for more lines)
M-ajump to the next sentence keeping current alignment
M-ejump to the previous sentence, keeping current alignment
C-c Nmove to field number N in a token line (C-c 0 moves to field number 10, i.e. MISC)

interactive editing

the default keybing C-c C-e calls a hydra for interactive editing. this enters an editing loop where you can navigate through the file or choose a field, edit it in a minibuffer, and press RET to confirm the edit; you can quit by pressing any unbound key or by pressing q. if you delete the field’s contents the empty field will be inserted automatically.

flycheck

setup

to be able to flycheck CoNLL-U buffers you need to:

  • obtain the validate.py script from the UD-tools repository (make sure you clone/download the whole repo, because the script depends on data and configuration files in there).
  • set the conllu-flycheck-validate.py-path variable to the filepath of the validate.py script. you can use M-x customize-variable conllu-flycheck-validate.py-path for this.

use

you can use the normal flycheck keybindings (here’s a nice summary). note that the validate.py demands a two-letter language code to do its validation; conllu-mode infers this from the file name, assuming it follows UD filename convention of starting with such a language code (as in pt_bosque-ud-test.conllu). if your file doesn’t start with a language code, flycheck will invoke the script with the default value of ud, which might throw spurious errors.

other features

  • highlighting comments, and upostag and deprel fields
  • truncate lines by default
  • show newline and tab characters using whitespace.el
  • aligning and unaligning column fields
  • jumping to next or previous sentence
  • jump to the token at point’s head

missing

if you’d like to have a feature implemented, you should file at ticket at the issue tracker. here is our wishlist of what we would like to implement in the future:

  • hiding columns
  • call a parser to create CoNLL-U output from a sentence
  • call external visualization tool

installation

you may install the latest versions from MELPA, or proceed to a manual installation:

MELPA

set MELPA up if you haven’t already and then do:

M-x package-install RET conllu-mode

manual installation

first you must install the dependencies: assuming you have a standard Emacs distribution, you need to install s and flycheck.

after having installed the dependencies, clone the repo, as in:

$ cd ~/some/path/
$ git clone https://github.com/odanoburu/conllu-mode

make sure that the repository is in the emacs load path and that the autoloads are properly set with

(add-to-list 'load-path "~/some/path/conllu-mode")
(autoload 'conllu-mode "conllu-mode" "Major mode for editing CoNLL-U files." t)
(add-to-list 'auto-mode-alist '("\\.conllu\\'" . conllu-mode))

in your .emacs.

contributions

yes, please! even comments from experienced elispers are welcome. just send an email or open an issue – if you’d like a suggestion on what to work on, take a look at the open issues or at the missing features (above).