Esempio n. 1
0
    def test_translate_1(self):
        """Tests translation where source language and target language are identical."""

        actual = translate('This is a test', 1, 'en', 'en')['translated_text']
        expected = 'This is a test'

        assert actual == expected
Esempio n. 2
0
 def test_translate(self):
     for in_data, out_data in self.data.items():
         with patch('app.requests.get',
                    return_value=Response(200, out_data)):
             self.assertDictEqual(app.translate(in_data), {
                 'in': in_data,
                 'out': out_data
             })
Esempio n. 3
0
 def test_translate(self):
     self.assertEqual(translate("100"), "cem")
     self.assertEqual(translate("1000"), "um mil")
     self.assertEqual(translate("10000"), "dez mil")
     self.assertEqual(translate("-100"), "menos cem")
     self.assertEqual(translate("23697"),
                      "vinte e três mil e seiscentos e noventa e sete")
     self.assertEqual(translate("-345"),
                      "menos trezentos e quarenta e cinco")
     self.assertEqual(translate("15"), "quinze")
     self.assertEqual(translate("2036"), "dois mil e trinta e seis")
Esempio n. 4
0
def beginn(data, intents):
    global lang
    #load users data into json
    datas = json.loads(data)
    #load nlu data into json
    intents = json.loads(intents)
    question = intents["input"]
    lang = intents["lang"]
    if (detect(question) != "en"):
        question = translate(question)

    answer = wolfram_Alpha(question, data)

    if (answer == False):
        return False
    else:
        return generate_answer(answer)
Esempio n. 5
0
def beginn(data, intents):
    global lang
    #load users data into json
    datas = json.loads(data)
    #load nlu data into json
    intents = json.loads(intents)
    question = intents["input"]
    lang = intents["lang"]
    # translations to english if necessary, wolframalpha only understands english
    if (detect(question) != "en"):
        question = translate(question)

    # ask wolframalpha
    answer = wolfram_Alpha(question, data)

    # if wolframalpha fails, return False
    if (answer == False):
        return False
    else:
        return generate_answer(
            answer), "https://a-ware.io/wp-content/uploads/2020/02/LOGO.png"
Esempio n. 6
0
def test_translate(fx_app):
    with fx_app.test_request_context():
        assert translate(u'테스트', 'ko', 'ja') == u'テスト'
        assert translate(u'テスト', 'ja', 'ko') == u'테스트'
Esempio n. 7
0
def test_word_not_found():
    assert translate('hhhhhhh') == "The word doesn't exist. Please double check it."
Esempio n. 8
0
def test_word_found():
    result = "rain: Precipitation in the form of liquid water drops with diameters greater than 0.5 millimetres.\n"
    result += "To fall from the clouds in drops of water.\n"
    assert translate('rain') == result
Esempio n. 9
0
def test_formatted_text_translate(fx_app):
    with fx_app.test_request_context():
        assert translate(u'<테스트>', 'ko', 'ja') == u'<テスト>'
Esempio n. 10
0
def test_formatted_text_translate(fx_app):
    with fx_app.test_request_context():
        assert translate(u'<테스트>', 'ko', 'ja') == u'<テスト>'
Esempio n. 11
0
 def test_status_codes(self):
     for code in app.CODES.keys():
         with patch('app.requests.get', return_value=Response(code)):
             res = app.translate('hi')
             self.assertIn('error', res)
Esempio n. 12
0
def cli(vm_file: str) -> None:
    click.echo(f"Translating <{vm_file}>")
    translate(vm_file)
    click.echo("Done!")
Esempio n. 13
0
def test_translate():
    assert translate(u'테스트', 'ko', 'ja') == u'テスト'
    assert translate(u'テスト', 'ja', 'ko') == u'테스트'
Esempio n. 14
0
def cli(target: str) -> None:
    click.echo(f"Translating <{target}>")
    translate(vm_file_or_directory_name=target)
    click.echo("Done!")
Esempio n. 15
0
        specfile = "console.spec"
    path = Path(".").absolute()
    spec = path / "app" / "utils" / "spec" / specfile
    tmp = path / "tmp"
    p = Popen("pyinstaller {spec} --distpath {path} --workpath {tmp}".format(
        spec=spec, path=path, tmp=tmp))
    p.wait()
    rm_dir(Path("./tmp"))
    sys.exit(0)


if __name__ == "__main__":
    if len(sys.argv) > 0 and sys.argv[-1] == "start":
        start_app(False)
        sys.exit(0)
    parser = ArgumentParser(description=translate("ma_args_description",
                                                  default_locale),
                            add_help=False)
    parser.add_argument("-c",
                        "--console",
                        help=translate("ma_args_console", default_locale),
                        action="store_true")
    parser.add_argument("-b",
                        "--build",
                        help=translate("ma_args_build", default_locale),
                        action="store_true")
    parser.add_argument("-h",
                        "--help",
                        help=translate("ma_args_help", default_locale),
                        action="help")
    args = parser.parse_args()
    if args.build:
Esempio n. 16
0
    def test_translate(self):

        input_seq = 'ATGGCCATTGTAATGGGCCGCTGAAAGGGTGCCCGATAG'

        self.assertEqual(translate(input_seq), 'MAIVMGR')
Esempio n. 17
0
def test_acronym_found():
    result = "NATO: An international organization created in 1949 by the"
    result += " North Atlantic Treaty for purposes of collective security.\n"
    assert translate('nato') == result
Esempio n. 18
0
def test_translate(fx_app):
    with fx_app.test_request_context():
        assert translate(u'테스트', 'ko', 'ja') == u'テスト'
        assert translate(u'テスト', 'ja', 'ko') == u'테스트'
Esempio n. 19
0
    def test_translate_2(self):
        """Tests translation where an empty text is given."""

        with pytest.raises(HTTPException):
            translate('', 1, 'en', 'ko')
Esempio n. 20
0
 def test_real_translate(self):
     for in_data, out_data in self.data.items():
         self.assertDictEqual(app.translate(in_data), {
             'in': in_data,
             'out': out_data
         })
Esempio n. 21
0
    def test_translate_4(self):
        """Tests translation where an invalid target language is given."""

        with pytest.raises(HTTPException):
            translate('The cake was a lie', 1, 'en', 'unknown')
Esempio n. 22
0
 def test_timeout(self):
     with patch('app.requests.get', side_effect=Timeout):
         self.assertDictEqual(app.translate('hi'), {'error': 'Таймоут'})
Esempio n. 23
0
def test_formatted_text_translate():
    assert translate(u'<테스트>', 'ko', 'ja') == u'<テスト>'
Esempio n. 24
0
def test_proper_noun_found():
    result = "Delhi: The largest metropolis by area and the second-largest metropolis by population in India.\n"
    assert translate('Delhi') == result