A comparison of libraries for named entity recognition
Tags: nlp, python, java, programming
Published: 2021-09-27 10:52:10

---
canonical_url: https://chuniversiteit.nl/papers/replicable-comparison-study-of-ner-software
---

> _What’s your favourite thing about SpaCy? Mine’s SpaCy._

**I read and summarise software engineering papers for fun, and today we’re having a look at [A replicable comparison study of NER software: StanfordNLP, NLTK, OpenNLP, SpaCy, GATE](https://doi.org/10.1145/3191697.3214341) (2019) by Schmitt et al.**

[Natural language processing](https://en.wikipedia.org/wiki/Natural_language_processing) (NLP) is a subfield of artificial intelligence that is dedicated to the understanding, processing, and generation of natural languages, like French and English.

[Named entity recognition](https://en.wikipedia.org/wiki/Named-entity_recognition) (NER) is a subtask of NLP that aims to identify entities (persons, locations) in texts. This can be used for things like machine translation, automated question answering, and automated text summarisation.

## Why it matters
If you need NER, there’s no need to implement it yourself. There are several popular libraries that can do this for you nowadays. Five of these libraries, [Stanford CoreNLP](https://stanfordnlp.github.io/CoreNLP/), [NLTK](https://www.nltk.org/), [OpenNLP](https://opennlp.apache.org/), [SpaCy](https://spacy.io/), and [GATE](https://gate.ac.uk/), were already mentioned in the title.

Which library is right for you depends on various criteria, like its performance, cost, documentation, license, and the programming language in which it is implemented.

Many of these libraries have been evaluated in comparison studies, but sadly not in a way that makes it easy to compare findings.

## How the study was conducted
This paper describes a comparison between the five aforementioned NER libraries, in a sufficiently clear and complete way, so that its results can be replicated.

The process looks roughly like this:

1. Selection of two corpora that are not domain-specific, freely available, and in English: the [Groningen Meaning Bank](https://gmb.let.rug.nl/) (GMB) and the [CoNLL 2003 corpus](https://www.aclweb.org/anthology/W03-0419.pdf).

1. Selection of five NER libraries that are free and open-source software, well-documented, available for Linux, and can recognise at least three types of entities: persons, organisations, and locations.

1. Comparison of each NER library’s generated NER annotations with annotations in the “gold data”, which contains the annotations that we’d expect. This is done by computing the precision, recall, and F-score for each library.

## What discoveries were made
The table below shows the results of the comparison. Don’t worry too much about its size and all the numbers, I’ve included a hangover-proof summary below the table.

<table>
  <thead>
    <tr>
      <td colspan="2"></td>
      <th colspan="3">CoNLL 2003</th>
      <th colspan="3">GMB</th>
    </tr>
    <tr>
      <th>Library</th>
      <th>Entity</th>
      <th>Precision</th>
      <th>Recall</th>
      <th>F-score</th>
      <th>Precision</th>
      <th>Recall</th>
      <th>F-score</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th rowspan="4">Stanford NLP</th>
      <td>Location</td>
      <td>91.30</td>
      <td>88.73</td>
      <td>90.00</td>
      <td>83.10</td>
      <td>63.64</td>
      <td>72.08</td>
    </tr>
    <tr>
      <td>Organisation</td>
      <td>86.32</td>
      <td>80.92</td>
      <td>83.53</td>
      <td>71.40</td>
      <td>47.42</td>
      <td>56.99</td>
    </tr>
    <tr>
      <td>Person</td>
      <td>92.72</td>
      <td>82.68</td>
      <td>87.41</td>
      <td>78.59</td>
      <td>84.70</td>
      <td>81.53</td>
    </tr>
    <tr>
      <td>Overall</td>
      <td>90.06</td>
      <td>73.67</td>
      <td><strong>81.05</strong></td>
      <td>79.81</td>
      <td>63.74</td>
      <td><strong>70.88</strong></td>
    </tr>
    <tr>
      <th rowspan="4">NLTK</th>
      <td>Location</td>
      <td>52.47</td>
      <td>65.47</td>
      <td>58.26</td>
      <td>77.13</td>
      <td>77.10</td>
      <td>77.12</td>
    </tr>
    <tr>
      <td>Organisation</td>
      <td>36.20</td>
      <td>24.80</td>
      <td>29.44</td>
      <td>42.06</td>
      <td>35.54</td>
      <td>38.53</td>
    </tr>
    <tr>
      <td>Person</td>
      <td>61.09</td>
      <td>66.11</td>
      <td>63.50</td>
      <td>38.07</td>
      <td>55.87</td>
      <td>45.28</td>
    </tr>
    <tr>
      <td>Overall</td>
      <td>51.78</td>
      <td>45.56</td>
      <td><strong>48.47</strong></td>
      <td>60.96</td>
      <td>63.91</td>
      <td><strong>62.40</strong></td>
    </tr>
    <tr>
      <th rowspan="4">GATE</th>
      <td>Location</td>
      <td>59.63</td>
      <td>78.63</td>
      <td>67.82</td>
      <td>79.03</td>
      <td>48.16</td>
      <td>59.85</td>
    </tr>
    <tr>
      <td>Organisation</td>
      <td>50.58</td>
      <td>21.29</td>
      <td>29.96</td>
      <td>45.08</td>
      <td>37.68</td>
      <td>41.05</td>
    </tr>
    <tr>
      <td>Person</td>
      <td>69.53</td>
      <td>62.67</td>
      <td>65.92</td>
      <td>46.53</td>
      <td>53.70</td>
      <td>49.86</td>
    </tr>
    <tr>
      <td>Overall</td>
      <td>61.48</td>
      <td>47.44</td>
      <td><strong>53.55</strong></td>
      <td>61.72</td>
      <td>46.78</td>
      <td><strong>53.22</strong></td>
    </tr>
    <tr>
      <th rowspan="4">OpenNLP</th>
      <td>Location</td>
      <td>76.54</td>
      <td>52.22</td>
      <td>62.08</td>
      <td>84.34</td>
      <td>45.84</td>
      <td>59.40</td>
    </tr>
    <tr>
      <td>Organisation</td>
      <td>38.06</td>
      <td>14.87</td>
      <td>21.39</td>
      <td>59.27</td>
      <td>30.64</td>
      <td>40.39</td>
    </tr>
    <tr>
      <td>Person</td>
      <td>83.94</td>
      <td>37.17</td>
      <td>51.52</td>
      <td>62.34</td>
      <td>41.98</td>
      <td>50.17</td>
    </tr>
    <tr>
      <td>Overall</td>
      <td>68.68</td>
      <td>30.44</td>
      <td><strong>42.18</strong></td>
      <td>37.35</td>
      <td>41.71</td>
      <td><strong>39.41</strong></td>
    </tr>
    <tr>
      <th rowspan="4">SpaCy</th>
      <td>Location</td>
      <td>73.38</td>
      <td>75.36</td>
      <td>74.36</td>
      <td>77.04</td>
      <td>56.64</td>
      <td>65.28</td>
    </tr>
    <tr>
      <td>Organisation</td>
      <td>40.95</td>
      <td>36.24</td>
      <td>38.45</td>
      <td>41.20</td>
      <td>36.50</td>
      <td>38.70</td>
    </tr>
    <tr>
      <td>Person</td>
      <td>66.89</td>
      <td>56.22</td>
      <td>61.09</td>
      <td>67.41</td>
      <td>69.14</td>
      <td>68.27</td>
    </tr>
    <tr>
      <td>Overall</td>
      <td>60.94</td>
      <td>49.01</td>
      <td><strong>54.33</strong></td>
      <td>66.15</td>
      <td>54.32</td>
      <td><strong>59.66</strong></td>
    </tr>
  </tbody>
</table>

Stanford NLP’s library is the only one that has (somewhat) high scores and blows the other libraries out of the water. The other four libraries have a roughly similar level of performance.

Note that Stanford NLP’s library performs especially well on the CoNLL 2003 dataset. This is because it comes with a classifier that was partially trained on CoNLL 2003! The scores for GMB are therefore more likely to be representative for real-world texts.

The results for Stanford NLP are similar to those from other studies. However, the accuracy for three of the other libraries (NLTK, GATE, and OpenNLP) (*) may differ as much as 66% from the values reported in existing studies. It is not clear what causes such huge discrepancies.

(*) _Apparently there weren’t any studies that evaluated SpaCy’s performance_