所以我正在学习python并重做一些旧项目.该项目涉及从命令行获取要翻译的字典和消息,以及翻译消息.(例如:"顺便说一下,你好,你怎么样"将被翻译成"顺便说一句,你好,你好吗".
我们使用教授提供的扫描仪来读取令牌和字符串.如有必要,我也可以在这里发布.继承人我的错误:
Nathans-Air-4:py1 Nathan$ python translate.py test.xlt test.msg
Traceback (most recent call last):
File "translate.py", line 26, in <module>
main()
File "translate.py", line 13, in main
dictionary,count = makeDictionary(commandDict)
File "/Users/Nathan/cs150/extra/py1/support.py", line 12, in makeDictionary
string = s.readstring()
File "/Users/Nathan/cs150/extra/py1/scanner.py", line 105, in readstring
return self._getString()
File "/Users/Nathan/cs150/extra/py1/scanner.py", line 251, in _getString
if (delimiter == chr(0x2018)):
ValueError: chr() arg not in range(256)
Run Code Online (Sandbox Code Playgroud)
继承人我的主要translate.py文件:
from support import *
from scanner import *
import sys
def main():
arguments = len(sys.argv)
if arguments …Run Code Online (Sandbox Code Playgroud) 这是我的任务.
我一直在和导师一起工作,这是我们迄今为止所提出的.
fun mult(a,b) =
let
val product = 0
in
if (a = 0) then
0
else
while a > 0 do
(
product := product + b;
if (a = 1) then
product
else
a:= a -1
);
end;
; //the function did not run at end;, so we added these two semicolons below
;
Run Code Online (Sandbox Code Playgroud)
输出是:
stdIn:102.11-103.6 Error: syntax error: deleting SEMICOLON END SEMICOLON
Run Code Online (Sandbox Code Playgroud)
在过去的两周里我才被介绍给SML而且我无法理解它.很感谢任何形式的帮助.
我使用Hedge传输在我的佳能 5D Mark III 上拍摄的Magic Lantern视频文件。
在 OS X 上,我可以使用 Automator 设置 bash 脚本,执行mlv_dump将文件从 MLV 传输到 cDNG 序列。
我目前使用的脚本是:
cd "$(dirname "$1")"
for f in "$@"; do
if [[ -f $f ]]; then
filename=${f##*/};
folder=${filename%.*}
mkdir "${folder}";
~/mlv_dump --dng $f -o ${folder}/${folder}_;
fi
done
Run Code Online (Sandbox Code Playgroud)
这可以轻松转换为 Windows 等效项吗?
谢谢,
托马斯
显然,可以在某些 Python 脚本中导入 Python Robot Framework 库。然而,有没有一种神奇的方法可以在Python脚本中导入Robot Framework资源文件呢?资源文件是用 RF 语法编写的,因此需要一些专用的 Python 模块来导入它(实际上将 RF 语法翻译为 Python)。也许类似的东西已经存在,甚至可以使用一些 RF 内置模块,就好像我理解正确一样,在脚本执行期间 RF 语法被转换为 Python 调用。
2018年6月18日更新:
正如 A. Kootstra 所建议的,可以使用以下命令在 Python 脚本中导入 Robot 关键字:
from robot.libraries.BuiltIn import BuiltIn
BuiltIn().import_resource('${EXECDIR}/resource.robot')
Run Code Online (Sandbox Code Playgroud)
但是,如何访问 Python 脚本中导入的 Robot 资源中的任何关键字?builtIn().import_resource 不会将任何处理程序返回到导入的库。
我会打电话
BuiltIn.call_method
Run Code Online (Sandbox Code Playgroud)
但它需要对象实例作为第一个参数。导入的资源文件也不存在于返回的字典中
globals()
Run Code Online (Sandbox Code Playgroud) 事情就是这样......我在我的应用程序中使用了一个 angular 4 模板,它有一个很好的工作翻译服务。问题是我不知道如何在代码中使用该管道。
在 HTML 中<span>{{ this.variable | traslate }}</span>,然后,该服务会转到一些 JSON 文件以查找文本并进行翻译。
这是我的 component.ts 中的代码
const SMALL_WIDTH_BREAKPOINT = 960;
@Component({
selector: 'app-mycomponent',
templateUrl: './mycomponent.component.html',
styleUrls: ['./mycomponent.component.scss']
})
export class TrackingComponent implements OnInit {
currentLang = 'es';
private mediaMatcher: MediaQueryList = matchMedia(`(max-width:
${SMALL_WIDTH_BREAKPOINT}px)`);
constructor(
public translate: TranslateService,
zone: NgZone,
private router: Router,
) {
const browserLang: string = translate.getBrowserLang();
translate.use(browserLang.match(/en|es/) ? browserLang : 'es');
this.mediaMatcher.addListener(mql => zone.run(() => {
this.mediaMatcher = mql;
}));
translate.use(this.currentLang);
}
ngOnInit() { } …Run Code Online (Sandbox Code Playgroud) 我目前正在使用 Google 翻译脚本代码将我网站中的文本转换为不同的语言。但是语言下拉菜单有很多选项,我只想有 3 种语言(卡纳达语、印地语、英语)
这是我正在使用的脚本
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
}
Run Code Online (Sandbox Code Playgroud)
谁能告诉我我怎么只有卡恩达语、英语和印地语作为语言选项
我想翻译(使用 DeepL) df [“text”] 列内的文本,其中每行都有一个句子。该文本不是用单一语言编写的,因此我想自动检测文本的语言并将翻译放在名为 df [“已翻译”] 的新列中。
谢谢
我有 DeepL 的免费身份验证密钥,但我不知道如何使用它,我是一个菜鸟。
我对列表理解有一点认识.我理解的表达方式:
[x * x | x <- [1..10]]
should output [1,4,9,16,25,36,49,64,81,100]
Run Code Online (Sandbox Code Playgroud)
并且该表达式的效果与以下内容相同:
map power [1..10]
power x = x * x
Run Code Online (Sandbox Code Playgroud)
现在,我必须找到以下函数的其他方法(就像上面这样):
[(x,y+z) | x <- [1..10], y <- [1..x], z <- [1..y]]
Run Code Online (Sandbox Code Playgroud)
我无法自己弄清楚没有错误,请帮助我
haskell list-comprehension translate higher-order-functions map-function
我正在搞乱一些字典,它应该将单词从一个文本框翻译成另一个文本框,反之亦然,但它并不像我喜欢的那样.该按钮的代码是:
private void button1_Click(object sender, EventArgs e)
{
string[] lines = File.ReadAllLines("C:/words.txt");
int i = 0;
var items = from line in lines
where i++ != 0
let words = line.Split('|')
where words.Count() > 1
select new
{
word = words[0],
translation = words[1]
};
foreach (var item in items)
{
if (textBox1.Text == item.word)
{
textBox2.Text = item.translation;
}
if (textBox2.Text == item.translation)
{
textBox1.Text = item.word;
}
else
{
label3.Text = ("not found");
}
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:不适用于"else if".
此刻我无法找出问题所在.我不断收到以下代码的相同错误消息:
package com.example.test1;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.util.Log;
import com.memetix.mst.language.Language;
import com.memetix.mst.translate.Translate;
public class MainActivity extends Activity {
private EditText text;
private EditText text1;
//private String translatedText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Translate.setClientId("myId");
Translate.setClientSecret("mySecret");
text = (EditText) findViewById(R.id.editText1);
text1 = (EditText) findViewById(R.id.editText2);
Button Trans1 = (Button)findViewById(R.id.button1);
Trans1.setOnClickListener(new View.OnClickListener(){
public void onClick(View view) {
String word = text.getText().toString();
try {
String translatedText = Translate.execute(word, Language.ENGLISH, Language.GERMAN);
text1.setText(translatedText);
} catch …Run Code Online (Sandbox Code Playgroud) translate ×10
python ×3
android ×1
angular ×1
bash ×1
c# ×1
deepl ×1
dictionary ×1
haskell ×1
html ×1
if-statement ×1
import ×1
iteration ×1
javascript ×1
line ×1
map-function ×1
pipe ×1
powershell ×1
sml ×1
split ×1
translation ×1
typescript ×1