Giter Site home page Giter Site logo

Comments (4)

abdnh avatar abdnh commented on September 27, 2024

Hi!

Did you follow the example I posted in the other issue? Can you tell me the steps you followed so far?
After creating a file in the providers folder as I explained there, you have to write a function to pull the examples from the file.
You can copy the from_tatoeba function in tr.py, changing just the filename to get a file like this:

import os
from typing import List
import csv
import re

from .. import consts

def from_tatoeba(word: str) -> List[str]:
    word = word.lower()
    pattern = re.compile(f"\\b{re.escape(word)}\\b")
    matches = []
    try:
        with open(
            os.path.join(consts.VENDOR_DIR, "jpn_sentences.tsv"),
            encoding="utf-8",
            newline="",
        ) as f:
            reader = csv.reader(f, delimiter="\t")
            for row in reader:
                sentence = row[2]
                if pattern.search(sentence):
                    matches.append(sentence)
    except FileNotFoundError:
        pass
    return matches

NAME = "Japanese"
PROVIDERS = [from_tatoeba]

The jpn_sentences.tsv used here must be inside the providers/vendor folder.
The zip files you download from https://tatoeba.org/en/downloads should be extracted to get the .tsv files.

from anki-incontext.

 avatar commented on September 27, 2024

Oh you're right, I'd already received your answer in the other post...Will try and get back to you :D

from anki-incontext.

abdnh avatar abdnh commented on September 27, 2024

An update on this: I've made the Tatoeba fetcher support more languages. You can download the new release from here: https://github.com/abdnh/anki-incontext/releases/tag/0.1

You only have to put the *.tsv file under the user_files/tatoeba folder for the add-on to pick it up now. Currently supported languages are listed here. I plan to make it so that it supports all Tatoeba languages automatically in the near future.

from anki-incontext.

soliviantar avatar soliviantar commented on September 27, 2024

This is working for Spanish with downloaded Tatoeba sentences. I tried making Spanish work with Glosbe and Tatoeba without the downloaded sentences, but it didn't work (but I just added "es" to the supported languages in glosbe.py and tatoeba.py .

In facto, Glosbe and Tatoeba (without database) is not working for English either (I'll open a new issue).

from anki-incontext.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.