FAQ Database Discussion Community


How to keep punctuation as a separate element in split_string in Prolog

string,split,prolog,swi-prolog,punctuation
I'm doing an assignment in Prolog (I'm a newbie) and I have a small problem. I know you can split a string to a list of elements in Prolog like this: split_string("Hello, here I am!"," "," .!?-_'",Temp). But this takes out the basic punctuation. It returns: Temp = ['Hello','here','I','am']. How...

What is difference between maketrans and replace in Python?

python,string,punctuation
Apologies if this has been asked before. I am trying to remove punctation from a string. I know how to do it, but I do not understand the difference between maketrans and replace in Python. More specifically, why does code scenario 1 below remove all the punctuation from incoming strings,...

How do I remove common elements from two lists?

python,list,punctuation
I have two lists such as the examples below (in reality, a is longer) and I would like to remove all common elements, in this case the punctuation given in list punctuation. a = [['A', 'man,', 'view,', 'becomes', 'mankind', ';', 'mankind', 'member', 'comical', 'family', 'Intelligences', '.'],['Jeans', 'lengthen', 'legs', ',', 'hug',...

regex remove punct removes non-punctuation characters in R

regex,r,punctuation
While filtering and cleaning text in Hebrew, I found that gsub("[[:punct:]]", "", txt) actually removes a relevant character. The character is "ק" and it is located in the "E" spot on the keyboard. Interestingly, the gsub function in R removes the "ק" character and then all words get messed up....

How to count punctuation marks in a String in java? [closed]

java,methods,count,punctuation
I need to write a program to count certain punctuation marks in a string. I have this code I thought would work, but at every charAt, i have an error that says the left hand of the assignment must be a variable. Need help fixing this public static void main(String[]...

Other ways to remove or ignore punctuation in JS besides regex?

javascript,regex,string,split,punctuation
I'm working through some beginner Coderbyte problems and I've come across an interesting dilemma. Here's the problem: "Using the JavaScript language, have the function LongestWord(sen) take the sen parameter being passed and return the largest word in the string. If there are two or more words that are the same...

R - using regex, set position before nth punct in string and delete what follows

regex,r,string,gsub,punctuation
I have a large data frame with a column of string data that currently contains a set of names and in certain instances an email address. I'd like to find a regular expression that will allow me to set the position just before the second comma in those cases with...

Removing punctuation marks form text in Scala - Spark

regex,scala,apache-spark,punctuation
This is one sample of my data: case time (especially it's purse), read manual care, follow care instructions make stays waterproof -- example, inspect rubber seals doors (especially battery/memory card door open time) xm "life support" picture . flip part bit flimsy guessing won't long . sound great altec speaker...

Going through very long strings, moving characters around [closed]

python,string,python-3.x,punctuation
The task is to read and search throughout text files, looking for specific characters (punctuation like {} or (), etc.) adding space around them when needed like this: "D'ya ken[John]Peel with" >>>>>> "D'ya ken [John] Peel with" # Blank Spaces've been added before and after brackets I don't really want...

Pharo punctuation marks [duplicate]

regex,pharo,punctuation
This question already has an answer here: Learning Regular Expressions [closed] 1 answer Is there any way to capture all the places in a String, where there are punctuation marks like '.,:;!?' Basically, am looking for a regex that captures all the above....

Stanford Word Segmenter for Chinese in Python how to return results without punctuation

python,stanford-nlp,punctuation,chinese-locale
I am trying to segment a Chinese sentence with the Stanford Word Segmenter in Python, but currently the results has punctuation marks in it. I want to return results without the punctuations, only the words. What is the best way to do that? I tried Googling for an answer, but...