예제 #1
0
 def test_automatický(self):
     word = run_through_module(Text('automatický'))
     self.assertEqual(word.get_text(), 'automatický')
     self.assertEqual(word.get_phonotypes(), [
         SUBUNIT, VOWEL, OBSTR, VOWEL, NASAL, VOWEL, OBSTR, VOWEL, OBSTR,
         OBSTR, VOWEL
     ])
예제 #2
0
 def test_знаходзілася(self):
     word = run_through_module(Text('знаходзілася'))
     self.assertEqual(word.get_text(), 'знаходзілася')
     self.assertEqual(word.get_phonotypes(), [
         OBSTR, NASAL, VOWEL, OBSTR, VOWEL, SUBUNIT, OBSTR, VOWEL, LIQUID,
         VOWEL, OBSTR, VOWEL
     ])
예제 #3
0
 def test_derivacija(self):
     word = run_through_module(Text('derivacija'))
     self.assertEqual(word.get_text(), 'derivacija')
     self.assertEqual(word.get_phonotypes(), [
         OBSTR, VOWEL, LIQUID, VOWEL, GLIDE, VOWEL, OBSTR, VOWEL, GLIDE,
         VOWEL
     ])
예제 #4
0
 def test_automaticky(self):
     word = run_through_module(Text('automatický'))
     self.assertEqual(word.get_text(), 'automatický')
     self.assertEqual(word.get_phonotypes(), [
         SUBUNIT, VOWEL, CONS, VOWEL, SONOR, VOWEL, CONS, VOWEL, CONS, CONS,
         VOWEL
     ])
예제 #5
0
 def test_українськогож(self):
     word = run_through_module(Text('українськогож'))
     self.assertEqual(word.get_text(), 'українськогож')
     self.assertEqual(word.get_phonotypes(), [
         VOWEL, CONS, SONOR, VOWEL, VOWEL, SONOR, CONS, SPEC, CONS, VOWEL,
         CONS, VOWEL, CONS
     ])
예제 #6
0
 def test_farmaceuticky(self):
     word = run_through_module(Text('farmaceutický'))
     self.assertEqual(word.get_text(), 'farmaceutický')
     self.assertEqual(word.get_phonotypes(), [
         CONS, VOWEL, SONOR, SONOR, VOWEL, CONS, SUBUNIT, VOWEL, CONS,
         VOWEL, CONS, CONS, VOWEL
     ])
예제 #7
0
 def test_sredozemlja(self):
     word = run_through_module(Text('sredozemlja'))
     self.assertEqual(word.get_text(), 'sredozemlja')
     self.assertEqual(word.get_phonotypes(), [
         OBSTR, LIQUID, VOWEL, OBSTR, VOWEL, OBSTR, VOWEL, NASAL, SUBUNIT,
         LIQUID, VOWEL
     ])
예제 #8
0
 def test_распаўсюджана(self):
     word = run_through_module(Text('распаўсюджана'))
     self.assertEqual(word.get_text(), 'распаўсюджана')
     self.assertEqual(word.get_phonotypes(), [
         LIQUID, VOWEL, OBSTR, OBSTR, VOWEL, GLIDE, OBSTR, VOWEL, SUBUNIT,
         OBSTR, VOWEL, NASAL, VOWEL
     ])
예제 #9
0
 def test_biologie(self):
     word = run_through_module(Text('biologie'))
     self.assertEqual(word.get_text(), 'bijologije')
     self.assertEqual(word.get_phonotypes(), [
         OBSTR, VOWEL, GLIDE, VOWEL, LIQUID, VOWEL, OBSTR, VOWEL, GLIDE,
         VOWEL
     ])
예제 #10
0
    def exportWords(self):
        """kidle/input/word"""
        self.logger.debug("Starting export")
        kindle = self.kindle_radio.isChecked()
        input_word = self.input_radio.isChecked()
        text = self.text_radio.isChecked()
        email = self.email_edit.text().strip(" ")
        password = self.pass_edit.text().strip(" ")
        self.lingualeo = Lingualeo(email, password)

        if not self.lingualeoOk():
            self.logger.debug("Export refused - Text")
            return

        if input_word:
            self.status_bar.showMessage(self.tr("Input > Lingualeo"))
            word = self.input_word_edit.text().lower().strip()
            context = self.input_context_edit.text()
            self.array = [{'word': word, 'context': context}]
            self.logger.debug("Export Input - Ready!")
        elif text:
            if not self.textOk():
                self.logger.debug("Export refused - Text")
                return
            self.file_name = self.text_path.text()
            self.status_bar.showMessage(self.tr("Txt > Lingualeo"))
            self.file_name = self.text_path.text()
            handler = Text(self.file_name)
            handler.read()
            self.array = handler.get()
            self.logger.debug("Export Text - Ready!")

        elif kindle:
            if not self.kindleOk():
                self.logger.debug("Export refused - Kindle")
                return
            self.file_name = self.kindle_path.text()
            self.status_bar.showMessage(self.tr("Kindle > Lingualeo"))
            handler = Kindle(self.file_name)
            handler.read(only_new_words=self.new_words_radio.isChecked())
            self.array = handler.get()
            self.logger.debug("Export Kindle - Ready!")
        before = len(self.array)
        self.logger.debug("{0} words before checking".format(before))
        if not self.wordsOk():
            self.logger.debug("Export refused - Words")
            return
        after = len(self.array)
        self.logger.debug("{0} words after checking".format(after))
        total = before
        duplicates = before - after
        try:
            dialog = ExportDialog(self.array, total, duplicates,
                                  self.lingualeo)
            dialog.closed.connect(self.clearMessage)
            dialog.exec_()
        except Exception:
            self.logger.exception("Dialog Exception")
            sys.exit()
예제 #11
0
    def test_union_with_foll_upper(self):
        words = [
            TextPunctuation('З', [None]),
            TextPunctuation('собою', [None, None, None, None, None]),
            End()
        ]
        result = run_through_module(words)

        self.assertEqual(result, [Text('зсобою'), End()])
예제 #12
0
    def test_hyphen(self):
        words = [
            TextPunctuation('сло-во',
                            [None, None, None, constants.HYPHEN, None, None]),
            End()
        ]
        result = run_through_module(words)

        self.assertEqual(result, [Text('слово'), End()])
예제 #13
0
    def test_quotation(self):
        words = [
            TextPunctuation('«слово»', [
                constants.PUNCT, None, None, None, None, None, constants.PUNCT
            ]),
            End()
        ]
        result = run_through_module(words)

        self.assertEqual(result, [Text('слово'), End()])
예제 #14
0
    def test_union_with_prec_upper(self):
        words = [
            TextPunctuation('українського', [
                None, None, None, None, None, None, None, None, None, None,
                None, None
            ]),
            TextPunctuation('Ж', [None]),
            End()
        ]
        result = run_through_module(words)

        self.assertEqual(result, [Text('українськогож'), End()])
예제 #15
0
    def run(self):
        pipe_in = self.get_pipes()[0]
        pipe_out = self.get_pipes()[1]
        self.is_running = True
        curr, foll = None, None

        while self.is_running:
            curr, foll = foll, get_word(pipe_in)
            self.is_end(foll)
            if not curr:
                continue

            cleaned_words = self.clean([curr, foll])
            curr, foll = cleaned_words[0], cleaned_words[1]
            if not curr:
                continue

            send_word(Text(curr.get_text()), pipe_out)

        send_word(foll, pipe_out)
예제 #16
0
 def test_srozpadem(self):
     word = run_through_module(Text('srozpadem'))
     self.assertEqual(word.get_text(), 'srozpadem')
     self.assertEqual(
         word.get_phonotypes(),
         [CONS, SONOR, VOWEL, CONS, CONS, VOWEL, CONS, VOWEL, SONOR])
예제 #17
0
 def test_vedomi(self):
     word = run_through_module(Text('vědomí'))
     self.assertEqual(word.get_text(), 'vědomí')
     self.assertEqual(word.get_phonotypes(),
                      [CONS, VOWEL, CONS, VOWEL, SONOR, VOWEL])
예제 #18
0
 def test_osm(self):
     word = run_through_module(Text('osm'))
     self.assertEqual(word.get_text(), 'osm')
     self.assertEqual(word.get_phonotypes(), [VOWEL, CONS, VOWEL])
예제 #19
0
 def test_biologie(self):
     word = run_through_module(Text('biologie'))
     self.assertEqual(word.get_text(), 'bijologije')
     self.assertEqual(word.get_phonotypes(), [
         CONS, VOWEL, SONOR, VOWEL, SONOR, VOWEL, CONS, VOWEL, SONOR, VOWEL
     ])
예제 #20
0
 def test_neurcity(self):
     word = run_through_module(Text('neurčitý'))
     self.assertEqual(word.get_text(), 'neurčitý')
     self.assertEqual(
         word.get_phonotypes(),
         [SONOR, VOWEL, VOWEL, SONOR, CONS, VOWEL, CONS, VOWEL])
예제 #21
0
    def test_apostrophe_U02BC(self):
        words = [TextPunctuation('вʼю', [None, None, None]), End()]
        result = run_through_module(words)

        self.assertEqual(result, [Text('вʼю'), End()])
예제 #22
0
 def test_pouzil(self):
     word = run_through_module(Text('použil'))
     self.assertEqual(word.get_text(), 'použil')
     self.assertEqual(word.get_phonotypes(),
                      [CONS, VOWEL, VOWEL, CONS, VOWEL, SONOR])
예제 #23
0
    def test_capital(self):
        words = [TextPunctuation('Київ', [None, None, None, None]), End()]
        result = run_through_module(words)

        self.assertEqual(result, [Text('київ'), End()])
예제 #24
0
 def test_pouze(self):
     word = run_through_module(Text('pouze'))
     self.assertEqual(word.get_text(), 'pouze')
     self.assertEqual(word.get_phonotypes(),
                      [CONS, SUBUNIT, VOWEL, CONS, VOWEL])
예제 #25
0
 def test_njegov(self):
     word = run_through_module(Text('njegov'))
     self.assertEqual(word.get_text(), 'njegov')
     self.assertEqual(word.get_phonotypes(),
                      [SUBUNIT, NASAL, VOWEL, OBSTR, VOWEL, GLIDE])
예제 #26
0
 def test_његов(self):
     word = run_through_module(Text('његов'))
     self.assertEqual(word.get_text(), 'његов')
     self.assertEqual(word.get_phonotypes(),
                      [NASAL, VOWEL, OBSTR, VOWEL, GLIDE])
예제 #27
0
 def test_maria(self):
     word = run_through_module(Text('maria'))
     self.assertEqual(word.get_text(), 'maria')
     self.assertEqual(word.get_phonotypes(), [SONOR, VOWEL, SONOR, SUBUNIT, VOWEL])
예제 #28
0
 def test_sex(self):
     word = run_through_module(Text('sex'))
     self.assertEqual(word.get_text(), 'sex')
     self.assertEqual(word.get_phonotypes(), [CONS, VOWEL, CONS])
예제 #29
0
from config import sources, auth
from service import Lingualeo
import sys
import traceback

email = auth.get('email')
password = auth.get('password')

try:
    export_type = sys.argv[1]
    if export_type == 'text':
        if len(sys.argv) == 3:
            source = sys.argv[2]
        else:
            source = sources.get('text')
        handler = Text(source)
    elif export_type == 'kindle':
        handler = Kindle(sources.get('kindle'))
    elif export_type == 'input':
        handler = Input(sys.argv[2:])
    elif export_type == 'subs':
        handler = Subs(sys.argv[2:])
    else:
        raise Exception('unsupported type')

    handler.read()

    lingualeo = Lingualeo(email, password)
    lingualeo.auth()
    exist = 0
    added = 0
예제 #30
0
 def test_црни(self):
     word = run_through_module(Text('црни'))
     self.assertEqual(word.get_text(), 'црни')
     self.assertEqual(word.get_phonotypes(), [OBSTR, VOWEL, NASAL, VOWEL])