Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Function question regarding logicals

1 回表示 (過去 30 日間)
Danny C
Danny C 2016 年 9 月 16 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I'm trying to create a function that checks if certain sentences follow some rules.
Provided files are:
  1. wordlist.mat
  2. sents.mat
  • All words in the sentence must be present in the wordlist(wordlist.mat).
  • Sentences are arranged in one of the following orders:
Noun -> Verb -> Noun/Adjective
(If first word is a noun, second should be a verb, and third should be a noun or adjective)
Adjective/Verb -> Noun -> Verb/Noun
(If first word is an adjective or verb, second should be noun, and third should be verb or noun)
I should output a logical true or false depending on whether the sentence is valid under these rules. The dictionary/wordlist and noun/verb/adjective lists are stored in the .mat file 'wordlist.mat'. The sentences are stored in 'sents.mat'.
Some more clues:
  • Words will always separated by spaces.
  • You are guaranteed to have three and only three words in the sentence.
  • The sentence will always end with some sort of punctuation.
  • Matching words with the various word lists should ignore case.
  • Any given word will only be found in at most one of the part­ of ­speech lists.
  • Any word contained in the dictionary/wordlist is guaranteed to occur in one of the other lists.
I finished coding but somehow my function isn't working in some test cases.
  2 件のコメント
James Tursa
James Tursa 2016 年 9 月 16 日
Can you post any code for us to look at? And what test cases are causing problems?
Walter Roberson
Walter Roberson 2016 年 9 月 16 日
編集済み: Walter Roberson 2016 年 9 月 16 日
"Punctuation that is part of words is always a nuisance in those kinds of problems", said O'Brion's assistant, a part-time programmer, at 5 o'clock; "Just my $0.02 worth!"

回答 (0 件)

この質問は閉じられています。

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by