matching

Python: How to return list of booleans to see if elements of one list in another list

孤者浪人 提交于 2019-12-02 03:28:52
I have two lists: A = [1,2,3,4,5,6,7,8] B = [2,3,4] and want to get a boolean list of length(A) where the element at each index indicates whether the element at the same index in A is in anywhere in the list B. The return value would be: [False, True, True, True, False, False, False, False] It would be easy to write a function, but want to know if there is a paradigmatic way of doing it in Python. In R, the counterpart would be which(A %in% b) use a list comprehension: In [164]: A = [1,2,3,4,5,6,7,8] In [165]: B = [2,3,4] In [166]: [x in B for x in A] Out[166]: [False, True, True, True, False,

python模块安装问题:no matching distribution found for XXX 或者 Read timed out.

孤街醉人 提交于 2019-12-01 15:35:36
https://blog.csdn.net/zhang_han666/article/details/88286010 看了很多解决问题的博客,亲测通过更换国内安装源和设置超时时间可以解决。 在 pip install XXX 命令的后面加上 --default-timeout=100 -i https://pypi.tuna.tsinghua.edu.cn/simple 即可。 来源: https://www.cnblogs.com/wushujun/p/11691027.html

【NQG】Paragraph-level Neural Question Generation with Maxout Pointer and Gated Self-attention Networks论文笔记

不问归期 提交于 2019-12-01 13:43:48
这篇文章主要处理了在问题生成(Question Generation,QG)中,长文本(多为段落)在seq2seq模型中表现不佳的问题。长文本在生成高质量问题方面不可或缺。 1. Introduction QG可以让对话系统更积极主动,也可以生成更多的问题来丰富QA(Question Answering)系统,同时在教育领域的阅读理解方面也有应用。 QG主要分为rule-based和neural approach: rule-based:可以看作是一个fill-and-rank模型,提取目的句子的相关实体,填入人工编写的模板中,再根据rank方法选择一个或几个最合适的。优点是很流畅,缺点是很依赖人工模板,很难做到open-domain。 neural approach:一般是改良的seq2seq模型。传统的encoder-decoder框架。 这篇文章针对的是answer-aware问题,即生成问题的答案显式得出现在给定文本的一部分或者几部分中。 针对段落生成的主要难点在于如何处理段落中的信息,即如何挑选出适合于生成问题的信息。 本文主要提出了一个改进的seq2seq模型,加入了maxout pointer机制和gated self-attention encoder。在之后的研究中可以通过加入更多feature或者policy gradient等强化学习的方式提升模型性能。 2.

关于STM32F103系列从大容量向中容量移植的若干问题

懵懂的女人 提交于 2019-12-01 13:27:00
一、把STM32F103大容量移植到STM32F103C8T6上的步骤: 1、换启动文件 startup_stm32f10x_cl.s ——互联型的器件 包括:STM32F105xx,STM32F107xx startup_stm32f10x_hd.s ——大容量器件 包括:STM32F101xx,STM32F102xx,STM32F103xx startup_stm32f10x_hd_vl.s ——大容量器件 包括:STM32F100xx startup_stm32f10x_ld.s ——小容量器件 包括:STM32F101xx,STM32F102xx,STM32F103xx startup_stm32f10x_ld_vl.s ——小容量器件 包括:STM32F100xx startup_stm32f10x_md.s ——中容量器件 包括:STM32F101xx,STM32F102xx,STM32F103xx startup_stm32f10x_md_vl.s ——中容量器件 - startup_stm32f10x_ld_vl.s: for STM32 Low density Value line devices - startup_stm32f10x_ld.s: for STM32 Low density devices - startup_stm32f10x_md_vl.s:

Insert some text after Nth matching pattern using sed

爱⌒轻易说出口 提交于 2019-12-01 13:11:52
How can I do so? I have multiple e.g. foobar patterns in my file, how can I add after e.g. the 4th one some_text? Does the following work for you? sed ':a;$!{N;ba};s/\(foobar\)/\1\nsome_text/4' inputfile For the input: $ cat inputfile line foobar foobar foobar line foobar line foobar line foobar line This would generate $ sed ':a;$!{N;ba};s/\(foobar\)/\1\nsome_text/4' inputfile line foobar foobar foobar line foobar some_text line foobar line foobar line Use -e on FreeBSD: sed -e :a -e '$!N' -e '$!ba' -e 's/\(foobar\)/\1\nsome_text/4' inputfile an awk version: awk '/foo/{x++} x==4{sub(/foo/,"

Insert some text after Nth matching pattern using sed

六眼飞鱼酱① 提交于 2019-12-01 11:24:20
问题 How can I do so? I have multiple e.g. foobar patterns in my file, how can I add after e.g. the 4th one some_text? 回答1: Does the following work for you? sed ':a;$!{N;ba};s/\(foobar\)/\1\nsome_text/4' inputfile For the input: $ cat inputfile line foobar foobar foobar line foobar line foobar line foobar line This would generate $ sed ':a;$!{N;ba};s/\(foobar\)/\1\nsome_text/4' inputfile line foobar foobar foobar line foobar some_text line foobar line foobar line Use -e on FreeBSD: sed -e :a -e '$

LIKE not working in TSQL

眉间皱痕 提交于 2019-12-01 11:09:30
Consider this TSQL : declare @b varchar(100) set @b = 'BANK-41' IF @b LIKE 'BANK_%' BEGIN print 'Wrong Matching' END Why does the TSQL match the string " BANK- " and " BANK_ "? In TSQL the underscore is a wildcard representing a single char. In order to escape in you need to wrap it with square brackets, like this: 'BANK[_]%' See this page: http://www.dirigodev.com/blog/web-development-execution/escaping-percent-and-underscore-characters-in-t-sql-like-clause/ An underscore in SQL Server is reserved for a wild card character, I think. You need to escape it.I think you can put it in brackets: %[

Matching two very very large vectors with tolerance (fast! but working space sparing)

*爱你&永不变心* 提交于 2019-12-01 09:12:40
consider I have two vectors. One is a reference vector/list that includes all values of interest and one samplevector that could contain any possible value. Now I want to find matches of my sample inside the reference list with a certain tolerance which is not fixed and depentent on the comparing values inside the vectors: matches: abs(((referencelist - sample[i])/sample[i])*10^6)) < 0.5 rounding both vectors is no option! for example consider: referencelist <- read.table(header=TRUE, text="value name 154.00312 A 154.07685 B 154.21452 C 154.49545 D 156.77310 E 156.83991 F 159.02992 G 159.65553

LIKE not working in TSQL

强颜欢笑 提交于 2019-12-01 08:40:43
问题 Consider this TSQL: declare @b varchar(100) set @b = 'BANK-41' IF @b LIKE 'BANK_%' BEGIN print 'Wrong Matching' END Why does the TSQL match the string " BANK- " and " BANK_ "? 回答1: In TSQL the underscore is a wildcard representing a single char. In order to escape in you need to wrap it with square brackets, like this: 'BANK[_]%' See this page: http://www.dirigodev.com/blog/web-development-execution/escaping-percent-and-underscore-characters-in-t-sql-like-clause/ 回答2: An underscore in SQL