sclite (SCTK),C++ 模板参数 Filter::Filter* 无效。 Cygwin
sclite (SCTK), C++ template argument, Filter::Filter* , is invalid. Cygwin
问题
我目前正在尝试安装 NIST 的 sclite
,它是 SCTK 2.4.0 (github or newer version) 的一部分。我正在尝试在 bash
中的 Cygwin
上安装。使用 make
.
完成安装
我能够通过进行 64 位编译来解决 file [format] not recognized
的问题,如我的 SO 帖子 README and as explained in detail in 末尾所述。
现在,我再次按照 installation instructions 并在输入 make all
后得到以下错误
In file included from main.cpp:20:0:
recording.h:122:36: error: template argument 2 is invalid
map<string, Filter::Filter*> filters;
^
recording.h:122:36: error: template argument 4 is invalid
make[3]: *** [makefile:59: main.o] Error 1
make[3]: Leaving directory
'/cygdrive/c/Me/programs/nist/sctk/src/asclite/core'
make[2]: *** [makefile:12: all] Error 2
make[2]: Leaving directory
'/cygdrive/c/Me/programs/nist/sctk/src/asclite'
make[1]: *** [makefile:12: all] Error 2
make[1]: Leaving directory '/cygdrive/c/Me/programs/nist/sctk/src'
make: *** [makefile:20: all] Error 2
有谁知道我可以做些什么来完成安装?
注意:回答这里的问题后,Cygwin 上的安装实际上并未完成。有一些事情要做 and ,我将在 SO 上发布我的进展以及关于下一步去哪里的问题。
我的尝试
我在 C++ 文档中没有找到关于 Filter
的任何信息,并且在克隆目录 ( $ find . -type f \( -name "*.h" -o -name "*.c" -o -name "*.cpp" \) -print0 | xargs -I'{}' -0 grep -Hn "Filter" {}
) 中搜索文件部分给出:
./src/asclite/core/checker.h:26:class Checker : public Filter
./src/asclite/core/filter.cpp:19: * Abstract interface to a Filter.
./src/asclite/core/filter.cpp:25:Filter::Filter()
./src/asclite/core/filter.cpp:30:Filter::~Filter()
./src/asclite/core/filter.h:26: * Abstract interface to a Filter.
./src/asclite/core/filter.h:28:class Filter
./src/asclite/core/filter.h:32: Filter();
./src/asclite/core/filter.h:34: virtual ~Filter();
...
据我所知,这意味着在命名空间 Filter
.
中有一个构造函数 Filter
这是 filter.cpp
的 "code part"
$ cat src/asclite/core/filter.cpp | tail -16
/**
* Abstract interface to a Filter.
*/
#include "filter.h" // class's header file
// class constructor
Filter::Filter()
{
}
// class destructor
Filter::~Filter()
{
}
这是 filter.h
的代码部分
$ cat src/asclite/core/filter.h | tail -27
#ifndef FILTER_H
#define FILTER_H
#include "stdinc.h"
#include "speech.h"
#include "speechset.h"
/**
* Abstract interface to a Filter.
*/
class Filter
{
public:
// class constructor
Filter();
// class destructor
virtual ~Filter();
virtual bool isProcessAllSpeechSet() = 0;
virtual unsigned long int ProcessSingleSpeech(Speech* speech) = 0;
virtual unsigned long int ProcessSpeechSet(SpeechSet* ref, map<string, SpeechSet*> &hyp) = 0;
virtual void LoadFile(const string& filename) = 0;
};
#endif // FILTER_H
系统详细信息
$ uname -a
CYGWIN_NT-6.1 CAP-D-ENG-INT3 2.10.0(0.325/5/3) 2018-02-02 15:16 x86_64 Cygwin
$ bash --version
GNU bash, version 4.4.12(3)-release (x86_64-unknown-cygwin) ...
$ gcc --version
gcc (GCC) 6.4.0 ...
$ g++ --version
g++ (GCC) 6.4.0 ...
$ make --version
GNU Make 4.2.1
Built for x86_64-unknown-cygwin ...
$ systeminfo | sed -n 's/^OS\ *//p'
Name: Microsoft Windows 7 Enterprise
Version: 6.1.7601 Service Pack 1 Build 7601
Manufacturer: Microsoft Corporation
Configuration: Member Workstation
Build Type: Multiprocessor Free
我的答案
(另请查看我在问题下的评论,描述 kaldi
解决方案。)
注意: 这个问题解决后又出现了一个问题。请参阅此答案的底部以获得帮助。
我一直在研究这个问题,我发现答案最终是改变了有问题的行(和其他一些行),正如我将要展示的那样。提醒一下,有问题的行来自文件 src/asclite/core/recording.h
recording.h:122:28: error: template argument 2 is invalid
map<string, Filter::Filter*> filters;
我改成了
map<string, ::Filter*> filters;
我也在第 157 和 164 行 src/asclite/core/recording.cpp
中做了相同的更改(Filter::Filter*
到 ::Filter*
),结果是:
157: map<string, ::Filter*>::iterator fi, fe;
164: ::Filter* ptr_elt = fi->second;
在寻找答案和解释时,我还发现 another page 有解决方案,但没有解释。
下面的解释中有一个"Let me clarify"说明,说明这只是安装的部分解决方案。
研究和(希望如此)解释
我首先注意到有问题的行前后的声明没有命名空间和双冒号,而我们的行有 Filter::Filter*
,如下所示:
$猫src/asclite/core/recording.h |头-n 130 |尾-24
地图对齐器;
/**
* contain all the available Scorer
*/
map<string, Scorer*> scorer;
/**
* contain all the available Segmentors
*/
map<string, Segmentor*> segmentors;
/**
* contain all the available Filters
*/
map<string, Filter::Filter*> filters;
/**
* Database for the optimization speaker alignment
*/
SpeakerMatch* m_pSpeakerMatch;
/** the logger */
static Logger* logger;
我首先尝试删除 Filter
命名空间和两个冒号 (::
)。我发现了一些网站(1, 2, 3,...),其中似乎没有名称空间和头文件中双冒号的示例。它们只在实现文件中。我删除了 Filter::
(从有问题的行和 recording.cpp
中的其他行),但这给了我
In file included from main.cpp:20:0:
recording.h:122:28: error: template argument 2 is invalid
map<string, Filter*> filters;
^
recording.h:122:28: error: template argument 4 is invalid
研究了双引号运算符(如here),并借助其他解决方案,我将Filter::Filter*
全部更改为::Filter
。
编译时出现一些警告,但安装过程的其余部分有效。 让我澄清一下 make config
和 make all
部分有效。 make test
部分有错误,在此处的另一个问题(待问)中有详细说明。但是,运行 make install
创建了我需要的可执行文件。
有关前置双冒号的信息,我从 another SO post 那里得到了一些帮助。构造函数前的两个冒号 "stuck on" 让我们知道它在全局范围内,即在 recording.h/.cpp 之外。这是必要的,因为在 recording.h/.cpp
中,还有另一个 Filter
方法用于创建 Recording
对象。 (随着我的写作,事情变得越来越清晰。)
$ cat src/asclite/core/recording.cpp | head -n 290 | tail -5
/**
* Filter the references and hypothesis with the availables filters.
*/
void Recording::Filter(const vector<string> & _filters)
{
$ cat src/asclite/core/recording.h | head -n 75 | tail -4
/**
* Filter the references and hypothesis with the availables filters.
*/
void Filter(const vector<string> & _filters);
我认为我们没有命名空间(即 ::
之前没有 Filter
)的原因已得到解释 here on SO。在这个 post 中,.cpp(实现)文件中的构造函数代码给出了解释:
Mems::Mems() //you don't actually need to use the class keyword in your .cpp file;
just the class name, the double colon, and the method name is enough to mark this
as a class method
据我了解,将 Filter::Filter
放入 Recording
对象的代码中表明 Filter::Filter
是 Recording
的 class 方法对象,但这没有意义,因为冒号前的第一个 Filter
显然将其标记为 Filter
对象的 class 方法。
如果此解释有误或不清楚,请随时修改。
此解决方案解决了问题中的问题,但在检查安装成功之前有 。
问题
我目前正在尝试安装 NIST 的 sclite
,它是 SCTK 2.4.0 (github or newer version) 的一部分。我正在尝试在 bash
中的 Cygwin
上安装。使用 make
.
我能够通过进行 64 位编译来解决 file [format] not recognized
的问题,如我的 SO 帖子 README and as explained in detail in
现在,我再次按照 installation instructions 并在输入 make all
In file included from main.cpp:20:0:
recording.h:122:36: error: template argument 2 is invalid
map<string, Filter::Filter*> filters;
^
recording.h:122:36: error: template argument 4 is invalid
make[3]: *** [makefile:59: main.o] Error 1
make[3]: Leaving directory
'/cygdrive/c/Me/programs/nist/sctk/src/asclite/core'
make[2]: *** [makefile:12: all] Error 2
make[2]: Leaving directory
'/cygdrive/c/Me/programs/nist/sctk/src/asclite'
make[1]: *** [makefile:12: all] Error 2
make[1]: Leaving directory '/cygdrive/c/Me/programs/nist/sctk/src'
make: *** [makefile:20: all] Error 2
有谁知道我可以做些什么来完成安装?
注意:回答这里的问题后,Cygwin 上的安装实际上并未完成。有一些事情要做
我的尝试
我在 C++ 文档中没有找到关于 Filter
的任何信息,并且在克隆目录 ( $ find . -type f \( -name "*.h" -o -name "*.c" -o -name "*.cpp" \) -print0 | xargs -I'{}' -0 grep -Hn "Filter" {}
) 中搜索文件部分给出:
./src/asclite/core/checker.h:26:class Checker : public Filter
./src/asclite/core/filter.cpp:19: * Abstract interface to a Filter.
./src/asclite/core/filter.cpp:25:Filter::Filter()
./src/asclite/core/filter.cpp:30:Filter::~Filter()
./src/asclite/core/filter.h:26: * Abstract interface to a Filter.
./src/asclite/core/filter.h:28:class Filter
./src/asclite/core/filter.h:32: Filter();
./src/asclite/core/filter.h:34: virtual ~Filter();
...
据我所知,这意味着在命名空间 Filter
.
Filter
这是 filter.cpp
$ cat src/asclite/core/filter.cpp | tail -16
/**
* Abstract interface to a Filter.
*/
#include "filter.h" // class's header file
// class constructor
Filter::Filter()
{
}
// class destructor
Filter::~Filter()
{
}
这是 filter.h
$ cat src/asclite/core/filter.h | tail -27
#ifndef FILTER_H
#define FILTER_H
#include "stdinc.h"
#include "speech.h"
#include "speechset.h"
/**
* Abstract interface to a Filter.
*/
class Filter
{
public:
// class constructor
Filter();
// class destructor
virtual ~Filter();
virtual bool isProcessAllSpeechSet() = 0;
virtual unsigned long int ProcessSingleSpeech(Speech* speech) = 0;
virtual unsigned long int ProcessSpeechSet(SpeechSet* ref, map<string, SpeechSet*> &hyp) = 0;
virtual void LoadFile(const string& filename) = 0;
};
#endif // FILTER_H
系统详细信息
$ uname -a
CYGWIN_NT-6.1 CAP-D-ENG-INT3 2.10.0(0.325/5/3) 2018-02-02 15:16 x86_64 Cygwin
$ bash --version
GNU bash, version 4.4.12(3)-release (x86_64-unknown-cygwin) ...
$ gcc --version
gcc (GCC) 6.4.0 ...
$ g++ --version
g++ (GCC) 6.4.0 ...
$ make --version
GNU Make 4.2.1
Built for x86_64-unknown-cygwin ...
$ systeminfo | sed -n 's/^OS\ *//p'
Name: Microsoft Windows 7 Enterprise
Version: 6.1.7601 Service Pack 1 Build 7601
Manufacturer: Microsoft Corporation
Configuration: Member Workstation
Build Type: Multiprocessor Free
我的答案
(另请查看我在问题下的评论,描述 kaldi
解决方案。)
注意: 这个问题解决后又出现了一个问题。请参阅此答案的底部以获得帮助。
我一直在研究这个问题,我发现答案最终是改变了有问题的行(和其他一些行),正如我将要展示的那样。提醒一下,有问题的行来自文件 src/asclite/core/recording.h
recording.h:122:28: error: template argument 2 is invalid
map<string, Filter::Filter*> filters;
我改成了
map<string, ::Filter*> filters;
我也在第 157 和 164 行 src/asclite/core/recording.cpp
中做了相同的更改(Filter::Filter*
到 ::Filter*
),结果是:
157: map<string, ::Filter*>::iterator fi, fe;
164: ::Filter* ptr_elt = fi->second;
在寻找答案和解释时,我还发现 another page 有解决方案,但没有解释。
下面的解释中有一个"Let me clarify"说明,说明这只是安装的部分解决方案。
研究和(希望如此)解释
我首先注意到有问题的行前后的声明没有命名空间和双冒号,而我们的行有 Filter::Filter*
,如下所示:
$猫src/asclite/core/recording.h |头-n 130 |尾-24 地图对齐器;
/**
* contain all the available Scorer
*/
map<string, Scorer*> scorer;
/**
* contain all the available Segmentors
*/
map<string, Segmentor*> segmentors;
/**
* contain all the available Filters
*/
map<string, Filter::Filter*> filters;
/**
* Database for the optimization speaker alignment
*/
SpeakerMatch* m_pSpeakerMatch;
/** the logger */
static Logger* logger;
我首先尝试删除 Filter
命名空间和两个冒号 (::
)。我发现了一些网站(1, 2, 3,...),其中似乎没有名称空间和头文件中双冒号的示例。它们只在实现文件中。我删除了 Filter::
(从有问题的行和 recording.cpp
中的其他行),但这给了我
In file included from main.cpp:20:0:
recording.h:122:28: error: template argument 2 is invalid
map<string, Filter*> filters;
^
recording.h:122:28: error: template argument 4 is invalid
研究了双引号运算符(如here),并借助其他解决方案,我将Filter::Filter*
全部更改为::Filter
。
编译时出现一些警告,但安装过程的其余部分有效。 让我澄清一下 make config
和 make all
部分有效。 make test
部分有错误,在此处的另一个问题(待问)中有详细说明。但是,运行 make install
创建了我需要的可执行文件。
有关前置双冒号的信息,我从 another SO post 那里得到了一些帮助。构造函数前的两个冒号 "stuck on" 让我们知道它在全局范围内,即在 recording.h/.cpp 之外。这是必要的,因为在 recording.h/.cpp
中,还有另一个 Filter
方法用于创建 Recording
对象。 (随着我的写作,事情变得越来越清晰。)
$ cat src/asclite/core/recording.cpp | head -n 290 | tail -5
/**
* Filter the references and hypothesis with the availables filters.
*/
void Recording::Filter(const vector<string> & _filters)
{
$ cat src/asclite/core/recording.h | head -n 75 | tail -4
/**
* Filter the references and hypothesis with the availables filters.
*/
void Filter(const vector<string> & _filters);
我认为我们没有命名空间(即 ::
之前没有 Filter
)的原因已得到解释 here on SO。在这个 post 中,.cpp(实现)文件中的构造函数代码给出了解释:
Mems::Mems() //you don't actually need to use the class keyword in your .cpp file; just the class name, the double colon, and the method name is enough to mark this as a class method
据我了解,将 Filter::Filter
放入 Recording
对象的代码中表明 Filter::Filter
是 Recording
的 class 方法对象,但这没有意义,因为冒号前的第一个 Filter
显然将其标记为 Filter
对象的 class 方法。
如果此解释有误或不清楚,请随时修改。
此解决方案解决了问题中的问题,但在检查安装成功之前有