split

How to remove certain words from text while keeping punctuation marks

How to remove certain words from text while keeping punctuation marks Question: I have the following code that removes Bangla words from given text. It can remove listed words from text successfully, but it fails to remove a word with punctuation. For example, here, from input text "বিশ্বের তথা দূষিত না বায়ুর না, শহরের না।", …

Total answers: 2

How to split python dataframe rows in one to one mapping form?

How to split python dataframe rows in one to one mapping form? Question: I’m trying to split python dataframe rows to one to one mapping format such that each new line represents the value in the same order as the column in front and if there is a single value on other columns copy their …

Total answers: 2

Scrolling text. Rearrange the character. Characters in a string from index zero to last. I want to get the following result

Scrolling text. Rearrange the character. Characters in a string from index zero to last. I want to get the following result Question: def scrolling_text(string: str) -> list: new_list = [] string = string.upper() for i in range(0, len(string)): string = string[i:] + string[:i] new_list.append(string) return new_list print(scrolling_text(‘robot’)) # ["ROBOT", "OBOTR", "BOTRO", "OTROB", "TROBO"] Asked By: …

Total answers: 1

numpy get indexes of connected array values

numpy get indexes of connected array values Question: I have a 1d numpy array that looks like this: a = np.array([1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1]) Is there a way to get the indexes of start and end of each cluster of values. So basically I …

Total answers: 1

Separate this string using these separator elements but without removing them from the resulting strings

Separate this string using these separator elements but without removing them from the resulting strings Question: import re input_string = "Sus cosas deben ser llevadas allí, ella tomo a sí, Lucy la hermana menor, esta muy entusiasmada. por verte hoy por la tarden sdsdsd" #result_list = re.split(r"(?:.s*n|.|n|;|,s*[A-Z])", input_string) result_list = re.split(r"(?=[.,;]|(?<=s)[A-Z])", input_string) print(result_list) Separate the …

Total answers: 2

Why when split a string into a list of substrings, without removing the separators, parts of this original string are lost in the splitting process?

Why when split a string into a list of substrings, without removing the separators, parts of this original string are lost in the splitting process? Question: import re from itertools import chain def identification_of_nominal_complements(input_text): pat_identifier_noun_with_modifiers = r"((?:l[oa]s|l[oa])s+.+?)s*(?=((VERB))" substrings_with_nouns_and_their_modifiers_list = re.findall(pat_identifier_noun_with_modifiers, input_text) separator_elements = r"s*(?:,|(,|)s*y)s*" substrings_with_nouns_and_their_modifiers_list = [re.split(separator_elements, s) for s in substrings_with_nouns_and_their_modifiers_list] substrings_with_nouns_and_their_modifiers_list = list(chain.from_iterable(substrings_with_nouns_and_their_modifiers_list)) …

Total answers: 1