sentence

How to scramble the words in a sentence - Python

橙三吉。 提交于 2021-02-11 18:19:57
问题 I have created the following code to scramble the letters in a word (except for the first and last letters), but how would one scramble the letters of the words in a sentence; given the input asks for a sentence instead of a word. Thank you for your time! import random def main(): word = input("Please enter a word: ") print(scramble(word)) def scramble(word): char1 = random.randint(1, len(word)-2) char2 = random.randint(1, len(word)-2) while char1 == char2: char2 = random.randint(1, len(word)

How to scramble the words in a sentence - Python

喜夏-厌秋 提交于 2021-02-11 18:18:15
问题 I have created the following code to scramble the letters in a word (except for the first and last letters), but how would one scramble the letters of the words in a sentence; given the input asks for a sentence instead of a word. Thank you for your time! import random def main(): word = input("Please enter a word: ") print(scramble(word)) def scramble(word): char1 = random.randint(1, len(word)-2) char2 = random.randint(1, len(word)-2) while char1 == char2: char2 = random.randint(1, len(word)

Reversing words within a string

青春壹個敷衍的年華 提交于 2021-02-11 15:33:07
问题 I am to reverse the words within a string. I feel like I'm headed in the right direction. But I keep getting wonky output and cant help but think it has to do with my strncat() function. Do any of you see any issues with out I've decided to handle it. I'm open to suggestion on other ways to do it. int main() { int ch, ss=0, s=0; char x[3]; char *word, string1[100], string2[100], temp[100]; x[0]='y'; while(x[0]=='y'||x[0]=='Y') { printf("Enter a String: "); fgets(string1, 100, stdin); if

BERT sentence embeddings: how to obtain sentence embeddings vector

天大地大妈咪最大 提交于 2021-02-11 13:41:14
问题 I'm using the module bert-for-tf2 in order to wrap BERT model as Keras layer in Tensorflow 2.0 I've followed your guide for implementing BERT model as Keras layer. I'm trying to extract embeddings from a sentence; in my case, the sentence is "Hello" I have a question about the output of the model prediction; I've written this model: model_word_embedding = tf.keras.Sequential([ tf.keras.layers.Input(shape=(4,), dtype='int32', name='input_ids'), bert_layer ]) model_word_embedding .build(input

Python 3 - How to capitalize first letter of every sentence when translating from morse code

依然范特西╮ 提交于 2021-02-08 07:48:57
问题 I am trying to translate morse code into words and sentences and it all works fine... except for one thing. My entire output is lowercased and I want to be able to capitalize every first letter of every sentence. This is my current code: text = input() if is_morse(text): lst = text.split(" ") text = "" for e in lst: text += TO_TEXT[e].lower() print(text) Each element in the split list is equal to a character (but in morse) NOT a WORD. 'TO_TEXT' is a dictionary. Does anyone have a easy

Split Sentences at Bullets and Numbering?

坚强是说给别人听的谎言 提交于 2020-06-09 03:42:24
问题 I am trying to input text into my word processor to be split into sentences first and then into words. An example paragraph: When the blow was repeated,together with an admonition in childish sentences, he turned over upon his back, and held his paws in a peculiar manner. 1) This a numbered sentence 2) This is the second numbered sentence At the same time with his ears and his eyes he offered a small prayer to the child. Below are the examples - This an example of bullet point sentence - This

Split Sentences at Bullets and Numbering?

℡╲_俬逩灬. 提交于 2020-06-09 03:42:08
问题 I am trying to input text into my word processor to be split into sentences first and then into words. An example paragraph: When the blow was repeated,together with an admonition in childish sentences, he turned over upon his back, and held his paws in a peculiar manner. 1) This a numbered sentence 2) This is the second numbered sentence At the same time with his ears and his eyes he offered a small prayer to the child. Below are the examples - This an example of bullet point sentence - This

Sentence Segmentation using Spacy

拥有回忆 提交于 2020-01-13 05:17:06
问题 I am new to Spacy and NLP. Facing the below issue while doing sentence segmentation using Spacy. The text I am trying to tokenise into sentences contains numbered lists(with space between numbering and actual text) . Like below. import spacy nlp = spacy.load('en_core_web_sm') text = "This is first sentence.\nNext is numbered list.\n1. Hello World!\n2. Hello World2!\n3. Hello World!" text_sentences = nlp(text) for sentence in text_sentences.sents: print(sentence.text) Output (1.,2.,3. are

How to divide a sentence into parts Java?

放肆的年华 提交于 2020-01-04 15:11:09
问题 How can I divide a sentence like "He and his brother playing football." into few part like "He and" , "and his" , "his brother" , "brother playing" and "playing football" . Is it possible to do that by using Java? 回答1: Assuming the "words" are always separated by a single space. Use String.split() String[] words = "He and his brother playing football.".split("\\s+"); for (int i = 0, l = words.length; i + 1 < l; i++) System.out.println(words[i] + " " + words[i + 1]); 回答2: You can do it using