sclite (SCTK),C++模板参数 Filter::Filter* 无效.西格温

sclite (SCTK), C++ template argument, Filter::Filter* , is invalid. Cygwin

本文关键字:Filter 无效 参数 SCTK C++ sclite      更新时间:2023-10-16

>问题

我目前正在尝试安装 NIST 的sclite,它是 SCTK 2.4.0(github 或更新版本(的一部分。我正在尝试在bashCygwin上安装。安装是使用make完成的。

我能够通过进行 64 位编译来解决file [format] not recognized问题,如自述文件末尾所述,以及在我的另一篇 SO 帖子中详细解释的那样。

现在,我再次按照安装说明进行操作,并在键入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上完成。之前和之后都有事情要做,我正在 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的"代码部分"

$ 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;

我也在src/asclite/core/recording.cpp的第157行和第164行做了同样的更改(Filter::Filter*::Filter*(,结果是:

157: map<string, ::Filter*>::iterator fi, fe;
164: ::Filter* ptr_elt = fi->second;

在寻找答案和解释时,我还发现了另一个有解决方案的页面,但没有解释。

下面的解释中有一个"让我澄清一下"注释,阐述了这只是安装的部分解决方案的事实。


研究和(希望(解释

我首先注意到有问题的行之前和之后的声明没有命名空间和双冒号,而我们的行有Filter::Filter*,如下所示:

$ cat src/asclite/core/recording.h | head -n 130 | tail -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

在研究了双引号运算符(例如这里(之后,在另一个解决方案的帮助下,我将所有Filter::Filter*更改为::Filter

它编译了一些警告,但安装过程的其余部分有效让我澄清一下make configmake all部分起作用了。make test部分有错误,详见这里的另一个问题(待问(。但是,运行make install会创建我需要的可执行文件。

有关前缀双冒号的信息,我从另一个 SO 帖子中得到了一些帮助。在构造函数之前,两个冒号"卡在"让我们知道它在全局范围内,即在 recording.h/.cpp 之外。这是必要的,因为在recording.h/.cpp中,创建的Recording对象还有另一种Filter方法。(在我写作的过程中,事情变得越来越清晰。

$ 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(在 SO 上得到了解释。在这篇文章中,给出了.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::FilterRecording对象的类方法,但这没有意义,因为冒号之前的第一个Filter显然将其标记为Filter对象的类方法。

如果此解释错误或不清楚,请随时修复它。

此解决方案解决了问题中的问题,但在成功检查安装之前还有更多工作要做。