欺骗在Mallet(终端,OSx)中使用带有空格的文件路径吗? [英] Trick to use file paths with spaces in Mallet (Terminal, OSx)?

查看:82
本文介绍了欺骗在Mallet(终端,OSx)中使用带有空格的文件路径吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有技巧可以通过Mac上的终端在Mallet中使用带空格的文件路径?

Is there a trick to be able to use file paths with spaces in Mallet through the terminal on mac?

例如,以下所有内容都会给我错误:

For example, all of the following give me errors:

转义空格

./bin/mallet import-dir  --input /Volumes/Macintosh\ HD/Users/MY_NAME/Desktop/en --output /Users/MY_NAME/Desktop/en.mallet --remove-stopwords TRUE --keep-sequence TRUE

双引号,不能转义

./bin/mallet import-dir --input "/Volumes/Macintosh HD/Users/MY_NAME/Desktop/en" --output /Users/MY_NAME/Desktop/en.mallet --remove-stopwords TRUE --keep-sequence TRUE

并且用双引号

./bin/mallet import-dir --input "/Volumes/Macintosh\ HD/Users/MY_NAME/Desktop/en" --output /Users/MY_NAME/Desktop/en.mallet --remove-stopwords TRUE --keep-sequence TRUE

最后加上单引号

./bin/mallet import-dir --input '/Volumes/Macintosh\ HD/Users/MY_NAME/Desktop/en' --output /Users/MY_NAME/Desktop/en.mallet --remove-stopwords TRUE --keep-sequence TRUE

他们都希望将文件夹视为多个文件夹,并在空间上分割:

They all want to treat the folder as multiple folders, split on the space:

Labels = 
   /Volumes/Macintosh\
   HD/Users/MY_NAME/Desktop/en
Exception in thread "main" java.lang.IllegalArgumentException: /Volumes/Macintosh\ is not a directory.
    at cc.mallet.pipe.iterator.FileIterator.<init>(FileIterator.java:108)
    at cc.mallet.pipe.iterator.FileIterator.<init>(FileIterator.java:145)
    at cc.mallet.classify.tui.Text2Vectors.main(Text2Vectors.java:322)

除了将所有文件重命名为下划线以外,是否还有其他解决方法? (我知道我不需要键入/Volumes/Macintosh \ HD/...,而只需从/Users开始.这只是一个示例.)

Is there anyway around this, other than renaming all of my files with spaces to underscores? (I understand that I don't need to type /Volumes/Macintosh\ HD/... but can just start at /Users. This was just an example.)

推荐答案

问题是import-dir设计为将多个目录用作输入.参数解析器将需要一种区分此用例和转义空间"用例的方法,请记住Windows路径可以以\结尾.

The issue is that import-dir is designed to take multiple directories as input. The argument parser would need a way to distinguish this use case from the "escaped space" use case, keeping in mind that Windows paths can end in \.

支持这两种情况的最佳方法可能是添加一个--single-input选项,该选项将其参数作为单个字符串.

The best way to support both cases might be to add a --single-input option that would take its argument as a single string.

我还发现,电子表格样式的import-file命令几乎总是比使用目录更可取.

I also find that the spreadsheet-style import-file command is almost always preferable to working with directories.

这篇关于欺骗在Mallet(终端,OSx)中使用带有空格的文件路径吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆