mortii / anki-morphs

A MorphMan fork rebuilt from the ground up with a focus on simplicity, performance, and a codebase with minimal technical debt.
https://mortii.github.io/anki-morphs/
Mozilla Public License 2.0
52 stars 7 forks source link

Having issues with spacy instructions #118

Closed wrinkledeth closed 7 months ago

wrinkledeth commented 8 months ago

Hello, I followed the spacy install guide for macos here

This is what i did to install the small chinese spacy model and integrate with anki.

mkdir anki_build
cd anki_build
venv 
activate
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade spacy six 'aqt[qt6]'
python -m spacy download zh_core_web_sm
deactivate 

.venv/bin/anki (new anki)

However, I do not see the chinese morphemizer in AnkiMorphs settings: image

Is there something i'm missing here?

EDIT: went through the docs again. It looks like i need to set up a parsing dictionary, but this link seems to be broken: https://mortii.github.io/anki-morphs/user_guide/installation/parsing-dictionary.html

Are there instructions for setting up new morphemizers/parsing dicitonaries for languages other than Japanese?


PS: I am a bit confused about the "inflected morphs" column shown here

Does this apply for chinese? It would be nice if you could provide some sameple frequency csv files for the common languages to make it easier for new users to onboard.


Cheers and thanks for making and maintaining this!!!!

mortii commented 8 months ago

@wrinkledeth oh, you're right, the macos instructions are broken. I'll try to fix it.

EDIT: went through the docs again. It looks like i need to set up a parsing dictionary, but this link seems to be broken: https://mortii.github.io/anki-morphs/user_guide/installation/parsing-dictionary.html

The parsing dictionary was just for japanese, but it's no longer necessary so I removed it from the guide.

PS: I am a bit confused about the "inflected morphs" column shown here

Does this apply for chinese?

For Chinese the two columns will just have the same values since it doesn't really have inflections.

It would be nice if you could provide some sameple frequency csv files for the common languages to make it easier for new users to onboard.

Absolutely! I'll add it to the roadmap.

mortii commented 8 months ago

@wrinkledeth

I forgot to put the open command first, e.g:

open spacyenv/bin/anki

It spawns a new terminal which is ugly, but at least it works :shrug:

mortii commented 8 months ago

I updated the macOS spaCy installation and I removed the dead link from note filter: morphemizers.

Let me know if it works!

wrinkledeth commented 8 months ago

Hello,

Using "open" does indeed fix the issue, and I can see the spacey Morphemizer in settings now.

image

However this seems to have re-introduced the bug i mentioned in #117 somehow.

When I hit browse, Anki crashes and I see the following:

image

Current Anki version:

image

I compared it to the Anki I grabbed from github which was working:

image

I guess PyQt needs to be downgraded from 6.6 to 6.5 to resolve this bug. Do you by chance know how to adjust the pip install command so that i'm getting Anki 23.12.1 with PyQt 6.5?

I will keep investigating.

wrinkledeth commented 8 months ago

Still cant figure out how to specify the qt minor version in the Anki install. Specifying qt5 resolves the problem but its not compatible with ankimorphs.

I've opened a question in anki forums: https://forums.ankiweb.net/t/how-to-install-anki-23-12-1-with-qt-6-5-3-with-pip/39196

Is there any other way for me to enable / integrate the spacey morphemizer with AnkiMorphs using the official / non-pip release binary? Is AnkiSpacy addon viable perhaps? https://github.com/rteabeault/AnkiSpacy @mortii

wrinkledeth commented 8 months ago

Solved. After the install instructions in your docs i had to:

curl https://raw.githubusercontent.com/ankitects/anki/main/python/requirements.qt6_mac.txt
pip install -r requirements.qt6_mac.txt

This version is no longer crashing. And i can use ankimorphs on anki23 on MacOS

image

Perhaps these temporary instructions can be added to the mac docs.

mortii commented 8 months ago

Is there any other way for me to enable / integrate the spacey morphemizer with AnkiMorphs using the official / non-pip release binary?

If you have python 3.9 then you don't have to setup a virtual environment, you can just use something like this:

python3.9 -m pip install --upgrade pip setuptools wheel
python3.9 -m pip install --upgrade spacy six
python3.9 -m spacy download ko_core_news_sm
python3.9 -m spacy download ru_core_news_sm

3.9 can be hard to download though, especially if one is not technologically inclined.

Is AnkiSpacy addon viable perhaps? https://github.com/rteabeault/AnkiSpacy @mortii

I wish, we investigated it in the 'spacy support' discussion: #13

Solved. After the install instructions in your docs i had to [...]

Nice! I'll add it.

mortii commented 8 months ago

3.9 can be hard to download though, especially if one is not technologically inclined.

I just realized that I could just link to the 'hard-to'find' python 3.9 installer, and that way people can just install 3.9 and not have to create a virtual environment.... that might be a million times easier :man_facepalming:

wrinkledeth commented 8 months ago

So are you saying if you python3.9 to install spacy, you can use the regular anki binary?

mortii commented 7 months ago

So are you saying if you python3.9 to install spacy, you can use the regular anki binary?

@wrinkledeth in theory yes. I just tested it on macos and it didn't quite work. I'll experiment and get back to you.

mortii commented 7 months ago

anki on macos does not read from the system wide python packages, but I got it working by prepending the python path during runtime. I'll try to make it more robust, it's very hacky atm.

mortii commented 7 months ago

After thinking about it some more, I am not so sure I like this approach. It could cause a tsunami of package conflicts and bad bugs... it would also require hardcoding different paths for different operating systems.

@wrinkledeth aside from this particular bug, do you think it's okay to launch anki from the virtual environment?

mortii commented 7 months ago

I have come up with a hybrid approach, install spacy in a virtual environment in the anki profile folder, that way the path is always the same across systems, and then you can launch the normal anki binary and have spacy working.

wrinkledeth commented 7 months ago

I have come up with a hybrid approach, install spacy in a virtual environment in the anki profile folder, that way the path is always the same across systems, and then you can launch the normal anki binary and have spacy working.

Nice this sounds awesome. Do you have some instructions so I can try to reproduce?

This is where I tried to install spacy: "/Users/MACUSER/Library/Application Support/Anki2/ANKIPROFILE/.venv/bin/spacy"

but it doesn't seem to be working.

I don't think i really grasp how Anki knows where to find spacy.

mortii commented 7 months ago

Nice this sounds awesome. Do you have some instructions so I can try to reproduce?

This is where I tried to install spacy: "/Users/MACUSER/Library/Application Support/Anki2/ANKIPROFILE/.venv/bin/spacy"

but it doesn't seem to be working.

I don't think i really grasp how Anki knows where to find spacy.

@wrinkledeth my bad, I should have specified that it's not possible in the current ankimorphs version, I have to change some code in spacy_wrapper.py to update the path. I'll push a new release as soon as i can.

EDIT: I got it to work on macos, now i just have to test it on the other operating systems and update the guide, then ill push a release.

mortii commented 7 months ago

@wrinkledeth It should now work in the v0.13 release.

Let me know if you experience any other problems, or if you have any suggestion :)

wrinkledeth commented 7 months ago

@mortii Its working perfectly. Thanks a lot!!!!!

xuiqzy commented 6 months ago

@mortii Do you have to install and use exactly Python 3.9 as hardcoded in the documentation currently because AnkiMorphs uses that? Or use the version that your Anki shows in the about info (the same as system python for me on Arch and the anki-bin AUR package)? Or can you just use any version newer than 3.9 or newer than what Anki uses, even if your Anki binary uses an older version for example?

I am not sure of the mechanism behind it, which python code requires and uses the library.

If it should match the Python version Anki uses, maybe that should be adapted in the installation instructions or if it is 3.9 every time, maybe it could be made clearer that this is because of the plugin, and you should not change it, even if your Anki uses a newer version? That would clear up some confusion for me (and maybe others) I think.

mortii commented 6 months ago

@xuiqzy I opened a new issue: #165

github-actions[bot] commented 5 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.