如何以编程方式从DefaultGazetteer删除查找 [英] How to remove a Lookup from DefaultGazetteer programatically

查看:75
本文介绍了如何以编程方式从DefaultGazetteer删除查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过添加/删除单词来教地名词典.

I need to teach Gazetteer by adding/removing words.

我知道如何添加新的Lookup ,但是何时我尝试将其删除,但尚未删除查找.

I know how to add new Lookup but when I've tried to remove it, the Lookup was not removed.

gazetter.remove("string to be found"); // returns false

请帮助!

推荐答案

(默认)地名词典中有两个单独的内容:

There are two separate things inside the (Default)Gazetteer:

  1. 有限状态机,用于搜索源文本.

  1. Finite state machine used for searching the source text.

线性定义,它代表字典中所有单词的列表.它不直接用于搜索文本.

Linear definition of the gazetteer which represents all the lists of words in the dictionary. It is not used directly for searching the text.

在启动时,它们的用法如下:

At the startup, they are used as follows:

  1. 从输入文件中读取线性定义.
  2. 根据定义构造有限状态机.

直接在地名词典实例上调用的方法gazetter.add()gazetter.remove()只能修改有限状态机.这些变化将在地名词典的行为上可见,但在线性定义中将不可见.

Methods like gazetter.add() or gazetter.remove() called directly on the gazetteer instance modify only the finite state machine. The changes will be visible on the gazetteer's behaviour but not in its linear definition.

线性定义中的方法仅修改线性定义.您必须使用store()reInit()根据线性定义更新地名词典内的有限状态机.之后,它们将同步,并且地名词典将查找新短语.这也意味着重新初始化后,仅在状态机上所做的更改将丢失.

Methods from the linear definition modify only the linear definition. You have to use store() and reInit() to update the finite state machine inside the gazetteer according to the linear definition. After that they will be in sync and the gazetteer will look for the new phrases. This also means that changes made only on the state machine will be lost after reinit.

如果您的代码返回了false,则该短语在有限状态机中不存在,并且地名词典无论如何都不会在文本中匹配该短语.

If your code returned false then the phrase was not present in the finite state machine and the gazetteer would not match such phrase in text anyway.

如果要从线性定义中删除该短语,则必须使用相应的方法(在我的上一个答案中简短描述).

If you want to remove the phrase from the linear definition you have to use respective methods (shortly described in my previous answer).

这篇关于如何以编程方式从DefaultGazetteer删除查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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