Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The Mean Length of Utterance (MLU) is one metric used by Speech Language Patholo

ID: 3888699 • Letter: T

Question

The Mean Length of Utterance (MLU) is one metric used by Speech Language Pathologists to measure the complexity of young children's language. Speech Language Pathologists divide the total number of morphemes (the smallest grammatical unit of language) by the total number of utterances (sentences) to get a value for the MLU. Sentences will look like the example below. Words are separated by a single space" "and bound morphemes are marked with a ". Here, 'ed' is a bound morpheme marking the verb "jump" as past tense, and the 's' is a bound morpheme marking the noun "trampoline" as plural. "I jump/ed on the trampoline/s" The total number of morphemes is the number of words (5) plus the number of /'s which indicate bound morphemes ,the sentence ateoamber of morphemes s 5 2-7. First, write a function countMorphemes that takes a string parameter containing the sentence ard returns an integer representing the total number of morphemes. You will want to loop over the characters in the sentence Then write a function printLongerUtterance that takes a string sentence1 and a string sentence2 as input and prints out the utterance with more morphemes. If both utterances have the same number of morphemes, print out the first utterance. You will want to call countMorphemes inside this function. For example: Test cout

Explanation / Answer

#include<iostream>
#include<string>
#include<sstream>

using namespace std;

int countMorphemes(string s){

    istringstream buf(s);
    int count = 0;
   
    for(string word; buf >> word; ){
       count = count++;
       for (int i = 0; i<word.size(); i++){
            if (word[i] == '/')
               count++;
       }   
    }
    return count;
}


string printLongerUttetraance(string s1, string s2){
    if (countMorphemes(s1) > countMorphemes(s2))
       return s1;
    if (countMorphemes(s1) < countMorphemes(s2))
       return s2;
    if (countMorphemes(s1) == countMorphemes(s2))
       return s1;


}

int main(){
  

    cout << countMorphemes("I am sing/ing.") << endl;
    cout << printLongerUttetraance("We play/ed with the lego/s", "Nana/'s doggy visit/ed today.") << endl;
    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote