diff --git a/README.md b/README.md index 84280a7..cb13c19 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ supports training on your own dataset. The models included in Lemmy were evaluated on the respective Universal Dependencies dev datasets. The Danish model scored > 99% accuracy, while the Swedish model scored > 97%. +All reported scores were obtained when supplying Lemmy with POS tags. You can use Lemmy as a spaCy extension, more specifcally a spaCy pipeline component. This is highly recommended and makes the lemmas easily accessible from the spaCy tokens. @@ -18,8 +19,10 @@ Lemmy makes use of POS tags to predict the lemmas. When wired up to the spaCy pi Lemmy has the benefit of using spaCy’s builtin POS tagger. Lemmy can also by used without spaCy, as a standalone lemmatizer. In that case, you will -have to provide the POS tags. Alternatively, you can train a Lemmy model which does not -depend on POS tags, though most likely the accuracy will suffer. +have to provide the POS tags. Alternatively, you can use Lemmy without POS tags, though +most likely the accuracy will suffer. Currrently, only the Danish Lemmy model comes with +a model trained for use without POS tags. That is, if you want to use Lemmy on Swedish +text without POS tags, you must train your own Lemmy model. Lemmy is heavily inspired by the [CST Lemmatizer for Danish](https://cst.dk/online/lemmatiser/). @@ -30,10 +33,35 @@ Danish](https://cst.dk/online/lemmatiser/). pip install lemmy ``` -## Usage +## Basic Usage Without POS tags ```python -import da_custom_model as da # name of your spaCy model +import lemmy + +# Create an instance of the standalone lemmatizer. +lemmatizer = lemmy.load("da") + +# Find lemma for the word 'akvariernes'. First argument is an empty POS tag. +lemmatizer.lemmatize("", "akvariernes") +``` + +## Basic Usage With POS tags + +```python +import lemmy + +# Create an instance of the standalone lemmatizer. +# Replace 'da' with 'sv' for the Swedish lemmatizer. +lemmatizer = lemmy.load("da") + +# Find lemma for the word 'akvariernes'. First argument is the user-provided POS tag. +lemmatizer.lemmatize("NOUN", "akvariernes") +``` + +## Usage with spaCy Model + +```python +import da_custom_model as da # replace da_custom_model with name of your spaCy model import lemmy.pipe nlp = da.load() @@ -41,7 +69,7 @@ nlp = da.load() # Replace 'da' with 'sv' for the Swedish lemmatizer. pipe = lemmy.pipe.load('da') -# Add the comonent to the spaCy pipeline. +# Add the component to the spaCy pipeline. nlp.add_pipe(pipe, after='tagger') # Lemmas can now be accessed using the `._.lemmas` attribute on the tokens. diff --git a/notebooks/da/04 examples.ipynb b/notebooks/da/04 examples.ipynb index 4e065e3..01c6c64 100644 --- a/notebooks/da/04 examples.ipynb +++ b/notebooks/da/04 examples.ipynb @@ -43,14 +43,14 @@ ], "source": [ "lemmatizer = lemmy.load(\"da\")\n", - "lemmatizer.lemmatize(\"\", full_form=\"skibene\")" + "lemmatizer.lemmatize(\"\", \"skibene\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## Using Lemy with spaCy\n", + "## Using Lemmy with spaCy\n", "This is an example of how to use lemma with spaCy. \n", "\n", "**Caution**: The Danish model included with spaCy is not trained for POS tagging. This model can not be used with Lemmy since the Lemmy pipeline component for spaCy requires POS tags. You must train your own spaCy model capable of POS tagging. The example below assumes you have your own model called `da_custom_model`."