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
200 Views Asked by Flu At
2
There are 2 best solutions below
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
- Add image to JCheckBoxMenuItem
- How to access invisible Unordered List element with Selenium WebDriver using Java
- Inheritance in Java, apparent type vs actual type
- Java catch the ball Game
- Access objects variable & method by name
- GridBagLayout is displaying JTextField and JTextArea as short, vertical lines
- Perform a task each interval
- Compound classes stored in an array are not accessible in selenium java
- How to avoid concurrent access to a resource?
- Why does processing goes slower on implementing try catch block in java?
- Redirect inside java interceptor
- Push toolbar content below statusbar
- Animation in Java on top of JPanel
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- Java Assign a Value to an array cell
Related Questions in TEXT
- Delete the extra space after special character in all the lines of text file
- Apply gaussian filter on text
- text show and hide with button php/js
- Get text from a section of a pdf page with IcePdf
- load word file (.docx) in richtextbox
- Display a specific line in a text file - android/java
- how to change text direction to the right slide of switch in android?
- C language - Read specific data from text file
- Read text file from specific position and store in two arrays
- How to animate text
- Detect repetition in text string / copied text
- Use MATLAB's webread to login to website and extract text
- LWJGL Drawing colored text to the screen issue
- Hide part of text temporarily, show after user clicks certain element
- Reading text file in java using scanner
Related Questions in TEXT-TO-SPEECH
- determining user's preferred AVSpeechSynthesisVoice for a given language
- Android Vocalizer TTS - select voice variant
- How to detect Text to speech status (speaking/not speaking) from java code on android?
- android TextToSpeech; switching between male and female voices
- how to change Text to Speech voice and how to insert characters into char array
- unable to add reference to windows.media.speechsynthesis.dll
- How to turn on text to speech engine in Twilio?
- TextToSpeech using WakefulBroadcastReceiver
- Voice Interaction App [Android]
- is it possible to get python to write text in another program
- Android - stop code midway?
- Cannot create an URI file from text-to-speech audio on UWP
- Odd behaviour in Google Web Speech API
- What do the Android Voice names / codes mean?
- AVspeechSynthesizer iOS text speech
Related Questions in TEXT-ANALYSIS
- Stanford Parser - Factored model and PCFG
- Performing Text Analytics on a text Column in Dataframe in R
- Splitting a document from a tm Corpus into multiple documents
- extract nouns and verbs from a text dataframe and save it in two different dataframes in R
- How to split a text into two meaningful words in R
- R Text Mining with quanteda
- Explore tab that tracks "topics" in google docs
- how to remove the html tags which are getting with the read more button
- Is it possible to find the posterior probability of topics generated with LDAvis occurring in a given document? How, if so?
- transform short word to original word
- Getting count of keywords using tm package in R
- Grouping texts into Buckets in R
- Identifying the subject of a sententce
- Count if a word occurs in each row of a 4 million observation data set
- Error message when using easyPubMed package in R
Related Questions in TEXT-RECOGNITION
- Tesseract - How to extract text from the image for the input coordinates?
- How can I implement text recognition on an iOS app?
- transform short word to original word
- How to scroll to a particular co-ordinate in Test Complete
- Stop detecting letters in Apple Vision, iOS, Swift
- I'd like to recognize the text of all pdfs on my computer and save them without moving them from their locations. Is it possible?
- OCR, tesseract.js: How do I match values to labels?
- Is there any iphone Class that converts images to text format?
- Recognizing text from a picture in delphi
- Which library to use to extract text from images?
- How do I select text from a scanned photo?
- Firebase ML Kit (Text_detection) - getConfident() return NULL
- Ml Kit text recognition not downloading model in Android
- How to grab subtitle from screenshot with PHP?
- Mathematica's TextRecognize not up to par
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)
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?
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.