问题列表 - 第28980页

Lucene:使用PrefixQuery进行分数计算

我在使用PrefixQuery进行分数计算时遇到问题.要更改每个文档的分数,在将文档添加到索引中时,我已使用setBoost来更改文档的提升.然后我创建PrefixQuery进行搜索,但结果没有根据提升进行更改.似乎setBoost完全不适用于PrefixQuery.请检查下面的代码:

 @Test
 public void testNormsDocBoost() throws Exception {
    Directory dir = new RAMDirectory();
    IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(Version.LUCENE_CURRENT), true,
            IndexWriter.MaxFieldLength.LIMITED);
    Document doc1 = new Document();
    Field f1 = new Field("contents", "common1", Field.Store.YES, Field.Index.ANALYZED);
    doc1.add(f1);
    doc1.setBoost(100);
    writer.addDocument(doc1);
    Document doc2 = new Document();
    Field f2 = new Field("contents", "common2", Field.Store.YES, Field.Index.ANALYZED);
    doc2.add(f2);
    doc2.setBoost(200);
    writer.addDocument(doc2);
    Document doc3 = new Document();
    Field f3 = new Field("contents", "common3", Field.Store.YES, Field.Index.ANALYZED);
    doc3.add(f3);
    doc3.setBoost(300);
    writer.addDocument(doc3);
    writer.close();

    IndexReader reader = IndexReader.open(dir);
    IndexSearcher searcher = new IndexSearcher(reader); …
Run Code Online (Sandbox Code Playgroud)

java lucene lucene.net

8
推荐指数
2
解决办法
1795
查看次数

有没有办法阻止触发器被禁用?

我在表上有一个永远不会被禁用的触发器.它执行某些检查,并且有时其他开发人员已禁用它来绕过它.这不好,所以我希望能够仅在此表上关闭触发器禁用.这可能吗?如果没有,请提出任何建议.谢谢.

解决方法:窥视响应似乎无法阻止它.也许获得警报是合适的.这是一篇很好的文章,遗憾的是它不能与EventData一起使用.也许在2008年,这已得到解决:http: //www.simple-talk.com/sql/database-administration/dml-trigger-status-alerts/

sql sql-server sql-server-2005 sql-server-2008

3
推荐指数
2
解决办法
1679
查看次数

通过self调用类方法

我在类中有一些类方法,名字很长(确切地说是TimingConfigController),我经常从类中调用这些方法(例如:[TimingConfigController intervalStringAt:i]),但长类名称困扰我,因为所有内联的语句都会变得非常长且不易阅读.

我正在读书,看看我是否能找到一个速记替代品,我在developer.apple.com上发现了这篇文章: 定义一个类

它说,除其他外,它

id newInstance = [[self alloc] init];
Run Code Online (Sandbox Code Playgroud)

是一个很好的方法来创建一个与自己相同的类的对象.据我所知,该语句使用自指针而不是类名称调用类方法,所以我在我的应用程序中尝试了,虽然它可能有用,但它会给出编译器警告.我真的不想发出警告.

那么,我的问题是,使用self来调用类方法可能和/或一个好主意?还有更好的选择吗?在.m文件的开头做一个#define Self TimingConfigController会不会很糟糕?或者我应该只服用药物并忍受烦恼?

objective-c

4
推荐指数
1
解决办法
1336
查看次数

是否有任何API可以在Windows中获取路径"C:\ Documents and Settings"?

是否有任何API来获取路径:c ++中的Windows中的"C:\ Documents and Settings"?

不:C:\ Documents and Settings\brianfu\My Documents.

非常感谢!

感谢luke的解决方案:

GetProfilesDirectory
Run Code Online (Sandbox Code Playgroud)

有用!

c++ windows api document

4
推荐指数
1
解决办法
2568
查看次数

这段代码是否遵循递归的定义?

我有一段代码,我怀疑它作为定义的递归实现.我的理解是代码必须调用自身,完全相同的功能.我还质疑是否以这种方式编写代码会增加额外的开销,这可以通过使用递归来看到.你的想法是什么?

class dhObject
{
public:
   dhObject** children;
   int numChildren;
   GLdouble linkLength; //ai 
   GLdouble theta; //angle of rot about the z axis
   GLdouble twist; //about the x axis
   GLdouble displacement; // displacement from the end point of prev along z
   GLdouble thetaMax;
   GLdouble thetaMin;
   GLdouble thetaInc;
   GLdouble direction;

   dhObject(ifstream &fin)
   {
      fin >> numChildren >> linkLength >> theta >> twist >> displacement >> thetaMax >> thetaMin;
      //std::cout << numChildren << std::endl;
      direction = 1;
      thetaInc = 1.0;
      if (numChildren > 0) …
Run Code Online (Sandbox Code Playgroud)

c++ recursion

3
推荐指数
2
解决办法
244
查看次数

禁止在C++中复制构造和复制赋值

为了禁止复制构建和复制分配,我已经看到了boost noncopyable类,并且在Google样式指南中看到了DISALLOW_COPY_AND_ASSIGN宏.有没有理由更喜欢其中一种技术,或者应该注意哪些微妙的差异?

c++

0
推荐指数
1
解决办法
492
查看次数

另一台机器上的目录 - 登录凭据

我的应用程序需要访问远程计算机上的文件,该计算机需要用户名和密码才能访问它.

我试图找出一个目录是否存在(使用Directory.Exists)来验证我是否可以建立'连接.

在使用远程目录时,有没有办法提供用户名和密码?目前Exists返回false.

干杯,

c# filesystems directory networking

6
推荐指数
1
解决办法
1万
查看次数

Do Doxygen配置文件是否支持变量?

例如,我将源代码路径设置为c:\ code\testapp\src.这是否可以作为我可以使用的var - 例如我可以在相对于此的位置吐出标签文件,而不是相对于doxygen的工作目录?我想我正在寻找像Ant如何为几乎所有东西定义变量的东西,这些可以重复使用; Doxygen对任何配置值都有特殊的变量吗?

我想的是$ PROJECT-NAME或%VERSION%或者其他......

doxygen

22
推荐指数
1
解决办法
6318
查看次数

如何用javascript替换字符串?

我有这个功能:

function emoticons(text){
    var url = "http://www.domain.it/images/smilies/";
    var emt = {
       ":D"  : 'icon_e_biggrin.gif',
       ":-D" : 'icon_e_biggrin.gif',       
       ":)"  : 'icon_e_smile.gif',
       ":-)" : 'icon_e_smile.gif',       
       ";)"  : 'icon_e_wink.gif',
       "';-)" : 'icon_e_wink.gif',

       ":("  : 'icon_e_sad.gif',
       ":-(" : 'icon_e_sad.gif',
       ":o"  : 'icon_e_surprised.gif',
       ":?"  : 'icon_e_confused.gif',
       "8-)" : 'icon_cool.gif',

       ":x"  : 'icon_mad.gif',
       ":P"  : 'icon_razz.gif'
    };

    for (smile in emt){        
        text   = text.replace(smile, '<img src="' + url + emt[smile] + '" class="emoticons" />');
    }

    return (text);
}
Run Code Online (Sandbox Code Playgroud)

如你所知.replace()转换第一次出现,如何在文本中替换多个表情符号?如何更改此功能?

非常感谢你!

javascript

5
推荐指数
1
解决办法
1658
查看次数

C++:避免​​使用只有空(de)构造函数的.cpp文件

当我有这样的头文件时:

#ifndef GAMEVIEW_H_
#define GAMEVIEW_H_

#include <SDL/SDL.h>

class GameView
{
public:
 GameView();
 virtual ~GameView();

 virtual void Update() = 0;
 virtual void Render(SDL_Surface* buffer) = 0;
};

#endif /* GAMEVIEW_H_ */
Run Code Online (Sandbox Code Playgroud)

我需要创建一个.cpp这样的文件:

#include "GameView.h"

GameView::~GameView()
{

}

GameView::GameView()
{
}
Run Code Online (Sandbox Code Playgroud)

这有点愚蠢.只是一个空构造函数和解构函数的.cpp文件.我想在头文件中简单地实现该方法.那更清洁了.

这该怎么做?

c++ header-files code-structure

1
推荐指数
2
解决办法
1696
查看次数