I used some word counting algorithm and by a closer look I was wondering because I got out less words than originally in the text because they count for example "it's" as one word. So I tried to find a solution but without any success, so I asked myself if their exist anything to transform a "short word" like "it's" to their "base words", say "it is".
transform short word to original word
205 views Asked by Flu At
2
There are 2 answers
2
Drew Kennedy
On
I just built this from scratch for the challenge. It seems to be working on my end. Let me know how it works for you.
public static void main(String[] args) {
String s = "it's such a lovely day! it's really amazing!";
System.out.println(convertText(s));
//output: it is such a lovely day! it is really amazing!
}
public static String convertText(String text) {
String noContraction = null;
String replaced = null;
String[] words = text.split(' ');
for (String word : words) {
if (word.contains("'s")) {
String replaceAposterphe = word.replace("'", "$");
String[] splitWord = replaceAposterphe.split('$');
noContraction = splitWord[0] + " is";
replaced = text.replace(word, noContraction);
}
}
return replaced;
}
I did this in C# and tried to convert it into Java. If you see any syntax errors, please point them out.
Related Questions in JAVA
- I need the BIRT.war that is compatible with Java 17 and Tomcat 10
- Creating global Class holder
- No method found for class java.lang.String in Kafka
- Issue edit a jtable with a pictures
- getting error when trying to launch kotlin jar file that use supabase "java.lang.NoClassDefFoundError"
- Does the && (logical AND) operator have a higher precedence than || (logical OR) operator in Java?
- Mixed color rendering in a JTable
- HTTPS configuration in Spring Boot, server returning timeout
- How to use Layout to create textfields which dont increase in size?
- Function for making the code wait in javafx
- How to create beans of the same class for multiple template parameters in Spring
- How could you print a specific String from an array with the values of an array from a double array on the same line, using iteration to print all?
- org.telegram.telegrambots.meta.exceptions.TelegramApiException: Bot token and username can't be empty
- Accessing Secret Variables in Classic Pipelines through Java app in Azure DevOps
- Postgres && statement Error in Mybatis Mapper?
Related Questions in TEXT
- Seeking Python Libraries for Removing Extraneous Characters and Spaces in Text
- How to increase quality of mathjax output?
- How to appropriately handle newlines and the escaping of them?
- How to store data with lots of subdata but keep easy and simple access in python
- Can I make this kind of radio button?
- I am findind it dificult to create a box containing text
- Replacing Text using Javascript
- How to set text inside a div using JavaScript and CSS
- How to get new text input after entering a password in a tab?
- How can I get my hero section to look like this?
- Find text and numbers Formatted: "Case: BE########" and format them, regardless of the number
- Auto style text in flutter
- Text analytics and Insights
- Combine an audio and a text file as one single file
- How to align side text and table horizontally in R-markdown
Related Questions in TEXT-TO-SPEECH
- How to Text To Speech a IA text generation that is streaming response
- Scroll textView along Text-to-Speech speaking highlight word change
- Text to speech, how to fast forward and backward?
- TTS doesn't initialize in Android 11
- Crash at flutter_tts initialysation : java.lang.NoSuchMethodError: android.speech.tts.TextToSpeech.getDefaultVoice
- Merging 6 ONNX Models into One for Unity Barracuda
- An Approach for Object Distance-Size Detection
- I cannot implement Text to Speech in my Unity project for Android
- How to implement Google Text-to-Speech in reactjs
- use SeamlessM4Tv2Model, I want to slow down the rate of speech of audio output
- Voice change in react native TSS
- Pause Discrepencies In Azure Speech Studio and Speech SDK
- How can I make a Python script utilize Windows Narrator to read only specific text output?
- RuntimeError: size mismatch for embedding.weight in Tacotron2\inference.ipynb
- Is there a way to use the Narrator Voice(Windows Acessibility) on text-to-speech code?
Related Questions in TEXT-ANALYSIS
- Why is stemming important for sentimental analysis
- How to search items in dictionary using list of strings?
- Stemming vs Lemmatization for financial text in python [NLTK]
- R- Text Analysis- Print specific text that contain a bi-gram
- necessary condition to fix weird lemma's?
- Python DBSCAN - How to plot clusters based on mean of vectors?
- scikit-learn CountVectorizer vocabulary with regex
- Extracting italic text from a document
- How to comma separate words when using Pypdf2 library
- Accessing Pattern library in Spyder
- Unable to install pattern
- How to remove the same and rare words in dataframe pandas?
- How to implement ontology in chatbots?
- How to convert dictionary to dataframe in Python
- Text Analysis and dealing with grammar, tense in R
Related Questions in TEXT-RECOGNITION
- After completely installation and done all the work i am getting Permission denied error do any one have solution
- Text Recognition from an Image(Live Camera) with React Native Expo
- Keyword : INV_FREQ Error occurs in latest version of Transformer, But does not in the version of 4.37.2
- Google ML Kit Text recognition v2 unbundled library having problem of recognizing numbers as characters in OCR Based Android App
- C# WinForms - Overlay with Text Recognition and adding Buttons
- Improving OCR Accuracy on Preprocessed ROI in Python with Pytesseract
- Removing dense grid lines & convert into clear image - opencv - python
- How can I tell Google Document AI Enterprise OCR to always assume one column?
- How to Read the text from images(OCR) where the font style is 7 segment font
- Vision Framework - Text Recognition - Cannot recognize some umlaut diacritics
- Flutter google_ml_kit - how to keep only the text recognition module
- How do I replace GMS TextRecognizer with ML Kit TextRecognizer in Camera Source?
- API Returning Partial Text Recognition from Images: How to Retrieve Complete Text?
- Is it possible to configure Google ML Kit's Text Recognition to only recognize numbers and letters found in standard English?
- Clustering word boxes into text blocks
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Well, basically you need to provide a data structure that maps abbreviated terms to their corresponding long versions. However, this will not be as simple as it sounds, for example you won't want to transform "The client's car." to "The client is car."
To manage these cases, you will probably need a heuristic that has a deeper understanding of the language you are processing and the grammar rules it incorporates.