小编Fea*_*Doe的帖子

Postgres - 全文搜索接受表情符号

我想创建一个全文搜索,接受查询上的表情符号,或其他类型的索引来搜索文本.例如,我有这个文本:Playa @CobolIquique h'和PostgreSQL在emojis上奇怪地解析它.

调试,使用SELECT * FROM ts_debug('english','Playa @CobolIquique h');我有以下结果:

结果1

我不知道为什么令牌被认为是空间符号.如果我调试解析器SELECT * FROM ts_parse('default', 'Playa @CobolIquique h');我只是得到相同的令牌和令牌类型ts_token_type('default')没有表情符号类型(或类似的东西).那么,我如何创建一个解析器来正确地将字符串与空格分开,并且不将emojis视为空格?或者如何创建可以在查询中使用表情符号的文本索引?

postgresql parsing full-text-search emoji

8
推荐指数
1
解决办法
726
查看次数

Java - 从String中删除\ u0000

我正在使用Twitter API,我有以下字符串,这是Proyecto de ingeniera comercial, actual Profesora de matemáticas \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000Enseña Chile
我想在PostgreSql中存储,但\u0000不接受,所以我想替换它.
我尝试使用,string= string.replaceAll("\\u0000", "");但它不起作用.我得到以下内容

String json = TwitterObjectFactory.getRawJSON(user);
System.out.println(json);
json = json.replaceAll("\\u0000", "");
System.out.println(json);
Run Code Online (Sandbox Code Playgroud)

输出(只有重要部分)

Proyecto de ingeniera comercial, actual Profesora de matemáticas \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000Enseña Chile
Proyecto de ingeniera comercial, actual Profesora de matemáticas \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000Enseña Chile
Run Code Online (Sandbox Code Playgroud)

如果我把这个部分放在java中的一个字符串中替换有效,但是如果我把它放在一个文本文件中,或者我直接为Twitter读它就不行了
所以我的问题是,如何从字符串中替换\ u0000?
顺便说一句,完整的字符串就是这个

{"utc_offset":null,"friends_count":83,"profile_image_url_https":"https://pbs.twimg.com/profile_images/2636139584/3a8455cd94045fa6980402add14796a9_normal.jpeg","listed_count":1,"profile_background_image_url":"http://abs.twimg.com/images/themes/theme1/bg.png","default_profile_image":false,"favourites_count":0,"description":"Proyecto de ingeniera comercial, actual Profesora de matemáticas \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000Enseña Chile","created_at":"Sat May 28 14:24:06 +0000 2011","is_translator":false,"profile_background_image_url_https":"https://abs.twimg.com/images/themes/theme1/bg.png","protected":false,"screen_name":"Fsquadritto","id_str":"306825274","profile_link_color":"0084B4","is_translation_enabled":false,"id":306825274,"geo_enabled":false,"profile_background_color":"C0DEED","lang":"es","profile_sidebar_border_color":"C0DEED","profile_location":null,"profile_text_color":"333333","verified":false,"profile_image_url":"http://pbs.twimg.com/profile_images/2636139584/3a8455cd94045fa6980402add14796a9_normal.jpeg","time_zone":null,"url":null,"contributors_enabled":false,"profile_background_tile":false,"entities":{"description":{"urls":[]}},"statuses_count":2,"follow_request_sent":false,"followers_count":36,"profile_use_background_image":true,"default_profile":true,"following":false,"name":"Fiorella Squadritto","location":"","profile_sidebar_fill_color":"DDEEF6","notifications":false,"status":{"in_reply_to_status_id_str":null,"in_reply_to_status_id":null,"possibly_sensitive":false,"coordinates":null,"created_at":"Fri Oct 12 17:40:35 +0000 2012","truncated":false,"in_reply_to_user_id_str":null,"source":"<a href=\"http://instagram.com\" rel=\"nofollow\">Instagram<\/a>","retweet_count":1,"retweeted":false,"geo":null,"in_reply_to_screen_name":null,"entities":{"urls":[{"display_url":"instagr.am/p/QsOQxTNfvQ/","indices":[49,69],"expanded_url":"http://instagr.am/p/QsOQxTNfvQ/","url":"http://t.co/GKziME7N"}],"hashtags":[{"indices":[24,34],"text":"eduinnova"}],"user_mentions":[{"indices":[35,47],"screen_name":"ensenachile","id_str":"57099132","name":"Enseña Chile","id":57099132}],"symbols":[]},"id_str":"256811615171792896","in_reply_to_user_id":null,"favorite_count":1,"id":256811615171792896,"text":"Amando las …
Run Code Online (Sandbox Code Playgroud)

java string character-encoding

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

JBrowserDriver需要一分多钟才能初始化

我正在使用JBrowserDriver从某些页面截取屏幕截图,但是当我创建驱动程序变量时,它需要超过一分钟(大约70秒).

  JBrowserDriver driver = new JBrowserDriver(Settings.builder().
  timezone(Timezone.AMERICA_NEWYORK).build());
Run Code Online (Sandbox Code Playgroud)

我在面对这个问题时直接从Maven运行JBrowserDriver

<dependency>
  <groupId>com.machinepublishers</groupId>
  <artifactId>jbrowserdriver</artifactId>
  <version>[0.12.0, 2.0)</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

找到导致此问题的根本原因或常见可能原因的任何提示?

java selenium-webdriver

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

在PostgreSQL上从JSON创建时间戳索引

我有一个名为场PostgreSQL的表datajsonb有大量的对象,我想打一个索引,以加快查询.我使用几行来测试数据(只有15行),但我不希望将来出现查询问题.我从Twitter API获取数据,因此在一周内我获得了大约10GB的数据.
如果我做正常索引

CREATE INDEX ON tweet((data->>'created_at'));

我得到一个文本索引,如果我做:

Create index on tweet((CAST(data->>'created_at' AS timestamp)));

我明白了

ERROR: functions in index expression must be marked IMMUTABLE

我试图让它"无意识"设置时区

date_trunc('seconds', CAST(data->>'created_at' AS timestamp) at time zone 'GMT')

但我仍然得到"不可变"的错误.那么,我如何从JSON中完成时间戳索引?我知道我可以用日期创建一个简单的专栏,因为它可能在时间上保持不变,但我想学习如何做到这一点.

postgresql jsonb

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

JAVA中多线程的全局总和错误

我是Java中多线程的新手,我做了一些代码来看看它是如何工作的.我有global = 0一个全局的int变量,并且有一个for循环我初始化了很多线程(100)以将1添加到我的全局变量中.
在代码的最后,结果应该是100,但不是.我有时在代码末尾99或任何其他数字(大约100).所以我的问题是,为什么线程在他们之间"打架"并且不能使总和正确?

public class test extends Thread {
    public static int global =0;
    public static void main(String[] args) throws Exception {
                for(int i=0;i<100;i++){
                String stream = String.valueOf(i);
                new test2(stream).start();
                }
                Thread.sleep(1000);
                System.out.println(global);
    }
    public test(String str) {
        super(str);
    }
    public void run() {
        int a = Integer.parseInt(getName());
        global = global+1;
        System.out.println("El hilo "+a+" tiene el número "+global);
    }
}
Run Code Online (Sandbox Code Playgroud)

我知道我不需要int a = Integer.parseInt(getName());,但我假装你将来使用这个名字.并且,如果我现在删除它,结果是错误的.

java

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