Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List Mathematica如何将列表列表转换为单个列表_List_Import_Functional Programming_Classification_Wolfram Mathematica - Fatal编程技术网

List Mathematica如何将列表列表转换为单个列表

List Mathematica如何将列表列表转换为单个列表,list,import,functional-programming,classification,wolfram-mathematica,List,Import,Functional Programming,Classification,Wolfram Mathematica,我试图在Mathematica中运行一个简单的文本分类器实验。下面的代码显示了培训模型的设置 B = Classify[{3 -> "The", 2 -> "Phrase", 1 -> "Best", 4 -> "Bad"}] 我已经在我手动整理的简单列表上进行了测试,效果很好,我希望完成的下一步是在从excel工作表导入的一列数据上运行它。我对Mathematica不太熟悉,对Python也比较熟悉。我遇到了麻烦,因为我似乎无法简单地调用列并在其上运行函数。我认为我的

我试图在Mathematica中运行一个简单的文本分类器实验。下面的代码显示了培训模型的设置

B = Classify[{3 -> "The", 2 -> "Phrase", 1 -> "Best", 4 -> "Bad"}]
我已经在我手动整理的简单列表上进行了测试,效果很好,我希望完成的下一步是在从excel工作表导入的一列数据上运行它。我对Mathematica不太熟悉,对Python也比较熟悉。我遇到了麻烦,因为我似乎无法简单地调用列并在其上运行函数。我认为我的问题是,导入时,列存储为列表列表。如何将其转换为一个文本列表,以便可以尝试运行上述内容。还有,如何存储输出?我想象我可以创建一个对象,但我对这种编程风格还是不熟悉

下面是我在excel中的数据示例;字面上是单列,没有标题

The Phrase
The Answer
The Phrases
Phrase
Answer
The Answer Phrase
The Answer Phrases
The Answers Phrase
The Question 
The Statement
Statement
Question
Questions
Statements
The Statements
Good
Bad
Neutral
Best
Better
The Best
The Bad
The Worst
Worst
The Offer
The Offers
Offer
一旦导入,如下所示:

`{{{"The Phrase"}, {"The Answer"}, {"The Phrases"}, {"Phrase"}, 
{"Answer"}, {"The Answer Phrase"}, {"The Answer Phrases"}, {"The 
Answers Phrase"}, {"The Question"}, {"The Statement"}, {"Statement"}, 
{"Question"}, {"Questions"}, {"Statements"}, {"The Statements"}, 
{"Good"}, {"Bad"}, {"Neutral"}, {"Best"}, {"Better"}, {"The Best"}, 
{"The Bad"}, {"The Worst"}, {"Worst"}, {"The Offer"}, {"The Offers"}, 
{"Offer"},....`

请尝试展平[…导入的数据…],看看这是否适用于最终有效的您,谢谢您的帮助!我建议您在Mathematica.stackexchange.com网站上发布更多Mathematica问题。注意,最外层的
{}
出现,因为当您导入excel时,它将作为工作表列表导入。无论何时导入单页excel工作簿,请立即使用
First@Import[file.xls]
来解决这个问题。