我有一个有一排排句子的Dataframe。现在,我想从Dataframe中删除所有包含字典/列表中>= x (e.g. 2 or 3)字数的句子,这些词可以看上去如下:dict = {"ice", "water", "rain"}
例如,如果x=2,我想删除句子ice and water are similar to each other,因为它有字典中的两个单词,但是没有ice melts away when it's warm,因为它在字典中只有不到两个单词。
我知道我能从字典中删除包含任何单词的句子:
df[~df.Sente
假设我有一个字符串列表(在我的例子中是电影名称),现在我有了一个新句子,它包含字符串列表中的一个字符串。我怎样才能找到这个句子的哪一个字符串?例如:
list_of_strings = ['20th century women', 'green is gold ', 'fire at sea']
sentence = 'Official Trailer | Green is gold - Releasing Tomorrow'
对于上述情况,解决办法应能找到含有绿色的句子是金的。请建议使用哪种算法来解决这个问题。Python中的
Python 3.5
这是我的密码:
str1 = input("Please enter a full sentence: ").lower()
print("Thank you, You entered:" , str1)
str2 = input("Now please enter a word included in your sentence in anyway you like: ").lower()
if str2 in str1:
print("That word was found!")
else:
我的代码接受句子,并在句子中找到一个给定的单词。
如果这个词在句子中,它需要说它已经找到了这个词,以及这个词所在的位置。
如果单词不在句子中,它应该显示一条错误消息。
我有这个:
print("Please insert your sentence without punctuation")
sentence=(input())
variable1='sentence'
print("Which word would you like to find in your sentence?")
word=input()
variable2='
我有一份单子上写着单词。我想知道这个词在用户要求的句子中的位置。(我使用python)例如,如果我有一个句子:"Hello world how are you doing today world?" 'World'出现在第一位和第八位。如果用户想知道单词'world'在这个句子中的位置,它会打印"The word world is in position 1 and 8"。我知道enumerate方法,但无法让它与输入或elif语句一起工作。无论单词发生多少次,我都想得到句子中任何单词的位置。
我试图从Python中的单个给定句子中创建一个可能的子语句列表,但无法弄清楚如何做到这一点。
例如:
sentence_1 = 'the dog jumped around'
我想把它分成:
['the',
'the dog'
'dog jumped'
'jumped around'
'the dog jumped'
'dog jumped around'
'the dog jumped around'
]
$comment="Computer is Nice but the manufacturer **some bad word for him** i don;t lkie him)"
现在我需要的是得到坏词的行和起点(坏词的位置),然后在坏评论表中将坏句子剪切并插入数据库,然后再把好注释插入到好注释表中,我很困惑如何做到这一点,任何php函数都能做到。
我有一个句子(字符串)和一个函数,它从WordNet生成给定单词的所有同义词。我想根据我的句子的同义词,列出所有可能的变体。
此外,我还想保持原句的顺序,意思排列应该只包含第一个词的同义词作为第一个词,第二个词的排列作为他们的第二个词等等。
例如,如果我的输入是:
"5 centimeters"
我的产出应该是:
5 cm
5 centimetres
5 centi-meters
5 centi-metres
five cm
five centimetres
five centi-meters
five centi-metres
在Scala中进行此操作的最佳方法是什么?谢谢!
我需要帮助。我有两份清单如下:
sentences = ['The green monkey green age the blue egg','How many yellow green monkey"s are in the green forest']
color =['orange', 'green', 'yellow', 'violet', 'blue']
totals = []
for sent in sentences:
print sent
for
早上好,
我试图从文件中提取包含"mais“一词的句子,但我遇到的问题是,提取出来的句子根本不包含"mais”,有时包含"jamais“。你知道为什么吗?我举了一个小例子来说明我的问题?
如下所示:我写的脚本使用了空格来标记句子,所以我只是举例说明了一小部分。这些行跟随读取文件并将其放入列表的行。然后在列表中循环找到包含"mais“的elt。
sentences_list_num = ['je ne suis pas mauvais mais lourd','je ne suis pas gentil', 'ce
使用Python,我试图在一个返回中捕获一个短语,加上前面的单词和一个接一个单词。
也就是说,从句子中..。
We want to see this phrase here and then again!
返回
see this phrase here
我最近得到的是..。
>>> s = 'We want to see this phrase here and then again!'
>>> re.search("\w*\sthis phrase\w*\s",s)
<_sre.SRE_Match object; sp
因此,我一直在尝试让这个脚本工作,但这是一个痛苦的背后。基本上,我想检查句子,看看它是否包含禁用的单词。如果一个给定的句子包含3个以上的单词(等于或更多),那么我希望它告诉我,这样我就可以发送警报。
到目前为止,我所拥有的:
public bool CheckSentence(string Message)
{
var count = 0;
foreach (WordFilter Filter in this._filteredWords.ToList())
{
if (Message.Contains(Filt