🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 18 (from laksa011)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

đź“„
INDEXABLE
âś…
CRAWLED
2 months ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH2.2 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://cs.stackexchange.com/questions/35951/detect-if-a-sentence-is-in-passive-voice
Last Crawled2026-02-08 20:52:39 (2 months ago)
First Indexednot set
HTTP Status Code200
Meta Titlenatural language processing - Detect if a sentence is in passive voice - Computer Science Stack Exchange
Meta Descriptionnull
Meta Canonicalnull
Boilerpipe Text
Given an English sentence, I am looking for a programmatic way to tell whether the sentence is written in passive voice. Currently, I just check if there is a was or were inside the sentence. If yes, then the function will say that the sentence is in passive voice (I do no not know even if this is true). Is there a better approach? I just want to make a simple detector for passive voice, I do not care much for accuracy and efficiency. Here what I ended up with: // http://english.stackexchange.com/questions/472/how-can-i-reliably-and-accurately-identify-the-passive-voice-in-writing-or-speec // forms of be, have and get int auxilary_verb(char* str) { if(strstr(str, "be ") || strstr(str, "been ") || strstr(str, "being ") || strstr(str, "have ") || strstr(str, "had ") || strstr(str, "was ") || strstr(str, "were ") || strstr(str, "wasn") || strstr(str, "weren") || strstr(str, "got ") || strstr(str, "get ") || strstr(str, "getting ")) { return 1; } else { return 0; } } // past participles of the verbs here http://web2.uvcs.uvic.ca/elc/sample/beginner/gs/gs_10.htm int past_participle_transitive_verb(char* str) { if(strstr(str, "brought ") || strstr(str, "cost ") || strstr(str, "given ") || strstr(str, "lent ") || strstr(str, "offered ") || strstr(str, "passed ") || strstr(str, "played ") || strstr(str, "read ") || strstr(str, "sent ") || strstr(str, "sung ") || strstr(str, "sent ") || strstr(str, "taught ") || strstr(str, "written ") || strstr(str, "bought ") || strstr(str, "get done ") || strstr(str, "left ") || strstr(str, "made ") || strstr(str, "owed ") || strstr(str, "paid ") || strstr(str, "promised ") || strstr(str, "refused ") || strstr(str, "shown ") || strstr(str, "taken ") || strstr(str, "told ") ) { return 1; } else { return 0; } } // Once a week, the house is cleaned by Tom. <- passive // By the end of the week, I'll be gone. <- not passive, but ok. int contains_by(char* str) { return (strstr(str, "by ") != NULL); } // how to find No direct object -> I don't know. // The subject of the verb phrase is the entity undergoing an action or having its state changed -> I don't know. int passive_voice(char* str) { // relax conditions, by applying || isntead of && if(auxilary_verb(str) || past_participle_transitive_verb(str) || contains_by(str)) { return 1; } else { return 0; } }
Markdown
[Skip to main content](https://cs.stackexchange.com/questions/35951/detect-if-a-sentence-is-in-passive-voice#content) #### Stack Exchange Network Stack Exchange network consists of 183 Q\&A communities including [Stack Overflow](https://stackoverflow.com/), the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. [Visit Stack Exchange](https://stackexchange.com/) 1. - [Tour Start here for a quick overview of the site](https://cs.stackexchange.com/tour) - [Help Center Detailed answers to any questions you might have](https://cs.stackexchange.com/help) - [Meta Discuss the workings and policies of this site](https://cs.meta.stackexchange.com/) - [About Us Learn more about Stack Overflow the company, and our products](https://stackoverflow.co/) 2. ### [current community](https://cs.stackexchange.com/) - [Computer Science](https://cs.stackexchange.com/) [help](https://cs.stackexchange.com/help) [chat](https://chat.stackexchange.com/?tab=site&host=cs.stackexchange.com) - [Computer Science Meta](https://cs.meta.stackexchange.com/) ### your communities [Sign up](https://cs.stackexchange.com/users/signup?ssrc=site_switcher&returnurl=https%3A%2F%2Fcs.stackexchange.com%2Fquestions%2F35951%2Fdetect-if-a-sentence-is-in-passive-voice) or [log in](https://cs.stackexchange.com/users/login?ssrc=site_switcher&returnurl=https%3A%2F%2Fcs.stackexchange.com%2Fquestions%2F35951%2Fdetect-if-a-sentence-is-in-passive-voice) to customize your list. ### [more stack exchange communities](https://stackexchange.com/sites) [company blog](https://stackoverflow.blog/) 3. [Log in](https://cs.stackexchange.com/users/login?ssrc=head&returnurl=https%3A%2F%2Fcs.stackexchange.com%2Fquestions%2F35951%2Fdetect-if-a-sentence-is-in-passive-voice) 4. [Sign up](https://cs.stackexchange.com/users/signup?ssrc=head&returnurl=https%3A%2F%2Fcs.stackexchange.com%2Fquestions%2F35951%2Fdetect-if-a-sentence-is-in-passive-voice) [![Computer Science](https://cs.stackexchange.com/Content/Sites/cs/Img/logo.svg?v=27188323e9e9)](https://cs.stackexchange.com/) 1. 1. [Home](https://cs.stackexchange.com/) 2. [Questions](https://cs.stackexchange.com/questions) 3. [Unanswered](https://cs.stackexchange.com/unanswered) 4. [AI Assist](https://stackoverflow.com/ai-assist) 5. [Tags](https://cs.stackexchange.com/tags) 6. [Chat](https://chat.stackexchange.com/) 7. [Users](https://cs.stackexchange.com/users) 8. [Companies](https://stackoverflow.com/jobs/companies?so_medium=cs&so_source=SiteNav) 2. Stack Internal Stack Overflow for Teams is now called **Stack Internal**. Bring the best of human thought and AI automation together at your work. [Try for free](https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=cs-community&utm_campaign=side-bar&utm_content=explore-teams) [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=cs-community&utm_campaign=side-bar&utm_content=explore-teams) 3. [Stack Internal]() 4. Bring the best of human thought and AI automation together at your work. [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=cs-community&utm_campaign=side-bar&utm_content=explore-teams-compact) **Stack Internal** Knowledge at work Bring the best of human thought and AI automation together at your work. [Explore Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=cs-community&utm_campaign=side-bar&utm_content=explore-teams-compact-popover) # [Detect if a sentence is in passive voice](https://cs.stackexchange.com/questions/35951/detect-if-a-sentence-is-in-passive-voice) [Ask Question](https://cs.stackexchange.com/questions/ask) Asked 11 years, 1 month ago Modified [9 years ago](https://cs.stackexchange.com/questions/35951/detect-if-a-sentence-is-in-passive-voice?lastactivity "2017-01-16 10:17:48Z") Viewed 5k times 3 \$\\begingroup\$ Given an English sentence, I am looking for a programmatic way to tell whether the sentence is written in passive voice. Currently, I just check if there is a `was` or `were` inside the sentence. If yes, then the function will say that the sentence is in passive voice (I do no not know even if this is true). Is there a better approach? *** I just want to make a *simple* detector for passive voice, I do not care much for accuracy and efficiency. Here what I ended up with: ``` // http://english.stackexchange.com/questions/472/how-can-i-reliably-and-accurately-identify-the-passive-voice-in-writing-or-speec // forms of be, have and get int auxilary_verb(char* str) { if(strstr(str, "be ") || strstr(str, "been ") || strstr(str, "being ") || strstr(str, "have ") || strstr(str, "had ") || strstr(str, "was ") || strstr(str, "were ") || strstr(str, "wasn") || strstr(str, "weren") || strstr(str, "got ") || strstr(str, "get ") || strstr(str, "getting ")) { return 1; } else { return 0; } } // past participles of the verbs here http://web2.uvcs.uvic.ca/elc/sample/beginner/gs/gs_10.htm int past_participle_transitive_verb(char* str) { if(strstr(str, "brought ") || strstr(str, "cost ") || strstr(str, "given ") || strstr(str, "lent ") || strstr(str, "offered ") || strstr(str, "passed ") || strstr(str, "played ") || strstr(str, "read ") || strstr(str, "sent ") || strstr(str, "sung ") || strstr(str, "sent ") || strstr(str, "taught ") || strstr(str, "written ") || strstr(str, "bought ") || strstr(str, "get done ") || strstr(str, "left ") || strstr(str, "made ") || strstr(str, "owed ") || strstr(str, "paid ") || strstr(str, "promised ") || strstr(str, "refused ") || strstr(str, "shown ") || strstr(str, "taken ") || strstr(str, "told ") ) { return 1; } else { return 0; } } // Once a week, the house is cleaned by Tom. <- passive // By the end of the week, I'll be gone. <- not passive, but ok. int contains_by(char* str) { return (strstr(str, "by ") != NULL); } // how to find No direct object -> I don't know. // The subject of the verb phrase is the entity undergoing an action or having its state changed -> I don't know. int passive_voice(char* str) { // relax conditions, by applying || isntead of && if(auxilary_verb(str) || past_participle_transitive_verb(str) || contains_by(str)) { return 1; } else { return 0; } } ``` - [natural-language-processing](https://cs.stackexchange.com/questions/tagged/natural-language-processing "show questions tagged 'natural-language-processing'") [Share](https://cs.stackexchange.com/q/35951 "Short permalink to this question") Cite [Improve this question](https://cs.stackexchange.com/posts/35951/edit) Follow [edited Jan 6, 2015 at 2:50](https://cs.stackexchange.com/posts/35951/revisions "show all edits to this post") asked Jan 5, 2015 at 2:32 [![gsamaras's user avatar](https://i.sstatic.net/5kF5N.jpg?s=64)](https://cs.stackexchange.com/users/16638/gsamaras) [gsamaras](https://cs.stackexchange.com/users/16638/gsamaras) 25155 silver badges1515 bronze badges \$\\endgroup\$ 2 - \$\\begingroup\$ "The boys watch the girls while the girls watch the boys who watch the girls go by..." I think you have to think about the "by". Or think of a supreme being, the have's and the have not's, I Got Rhythm, and so on. \$\\endgroup\$ gnasher729 – [gnasher729](https://cs.stackexchange.com/users/17408/gnasher729 "32,672 reputation") 2016-11-25 16:19:42 +00:00 Commented Nov 25, 2016 at 16:19 - 1 \$\\begingroup\$ I don't understand what you're asking. If you want something simple and don't care about accuracy, then detecting "was" and "were" is fine: it's simple and inaccurate. Indeed, just returning `true` for all inputs is also simple and inaccurate. So what are you actually looking for? \$\\endgroup\$ David Richerby – [David Richerby](https://cs.stackexchange.com/users/9550/david-richerby "82,662 reputation") 2017-01-16 12:51:13 +00:00 Commented Jan 16, 2017 at 12:51 [Add a comment](https://cs.stackexchange.com/questions/35951/detect-if-a-sentence-is-in-passive-voice "Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.") \| ## 2 Answers 2 Sorted by: [Reset to default](https://cs.stackexchange.com/questions/35951/detect-if-a-sentence-is-in-passive-voice?answertab=scoredesc#tab-top) 4 \$\\begingroup\$ detecting passive voice is an AI application also used/ implemented in [grammar checker/ correction software](http://en.wikipedia.org/wiki/Grammar_checker) with proprietary algorithms. there is a complexity/ accuracy tradeoff. simpler algorithms can be useful and better accuracy requires more sophisticated algorithms. here are two papers on the subject including a masters thesis (60p). final link is an open source implementation of passive voice checking used in OpenOffice. - [Learning to Identify Reduced Passive Verb Phrases with a Shallow Parser](http://www.cs.utah.edu/~riloff/pdfs/aaai08.pdf) Igo, Riloff AAAI-2008 - [IDENTIFYING REDUCED PASSIVE VOICE CONSTRUCTIONS IN SHALLOW PARSING ENVIRONMENTS](http://www.cs.utah.edu/~riloff/pdfs/Official-Igo-MSThesis.pdf) / Igo - [open source grammar checker for open office](http://extensions.openoffice.org/en/project/after-deadline-grammar-checker) including passive voice checking [Share](https://cs.stackexchange.com/a/35987 "Short permalink to this answer") Cite [Improve this answer](https://cs.stackexchange.com/posts/35987/edit) Follow answered Jan 5, 2015 at 21:27 [![vzn's user avatar](https://www.gravatar.com/avatar/b7026b87c51690329e9ef5b74928bbfb?s=64&d=identicon&r=PG)](https://cs.stackexchange.com/users/699/vzn) [vzn](https://cs.stackexchange.com/users/699/vzn) 11\.2k11 gold badge2828 silver badges5252 bronze badges \$\\endgroup\$ 3 - \$\\begingroup\$ Thanks for the links! From the last link, I downloaded the package, but it has many things. Any help? The other links are also interesting. However, I was looking for something simple, like a pseudocode or something. \$\\endgroup\$ gsamaras – [gsamaras](https://cs.stackexchange.com/users/16638/gsamaras "251 reputation") 2015-01-05 21:46:56 +00:00 Commented Jan 5, 2015 at 21:46 - \$\\begingroup\$ a simple approach could use part-of-speech tagging and maybe a small dictionary of verbs & variants & attempt to identify subj, look at where the verb is relative to the subject etc., but am not aware of a simple algorithm. an option might be to come up with a set of training sentences and just work up a solution via trial & error & see what accuracy is possible. \$\\endgroup\$ vzn – [vzn](https://cs.stackexchange.com/users/699/vzn "11,190 reputation") 2015-01-05 21:52:09 +00:00 Commented Jan 5, 2015 at 21:52 - \$\\begingroup\$ Yes, this trial & error is what I am trying to do, but I can't find any simple rules to apply to (like the ones in my post, which are wrong after all). I will keep searching. \$\\endgroup\$ gsamaras – [gsamaras](https://cs.stackexchange.com/users/16638/gsamaras "251 reputation") 2015-01-05 22:09:24 +00:00 Commented Jan 5, 2015 at 22:09 [Add a comment](https://cs.stackexchange.com/questions/35951/detect-if-a-sentence-is-in-passive-voice "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \| 7 \$\\begingroup\$ I recommend you look at methods in the NLP literature for parsing a sentence and identifying its structure, classifying the tense of the sentence and the words present in it, and identifying the subject and object of the sentence. That should help you build a more accurate classifier. If you extract suitable features, given the parse tree, and then apply a suitable machine learning algorithm, you might get a more effective classifier. [Share](https://cs.stackexchange.com/a/35960 "Short permalink to this answer") Cite [Improve this answer](https://cs.stackexchange.com/posts/35960/edit) Follow answered Jan 5, 2015 at 6:19 [![D.W.'s user avatar](https://i.sstatic.net/mYIzP.png?s=64)](https://cs.stackexchange.com/users/755/d-w) [D.W.](https://cs.stackexchange.com/users/755/d-w)♦ 169k2323 gold badges236236 silver badges520520 bronze badges \$\\endgroup\$ 0 [Add a comment](https://cs.stackexchange.com/questions/35951/detect-if-a-sentence-is-in-passive-voice "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \| **[Protected question](https://cs.stackexchange.com/help/privileges/protect-questions)**. To answer this question, you need to have at least 10 reputation on this site (not counting the [association bonus](https://meta.stackexchange.com/questions/141648/what-is-the-association-bonus-and-how-does-it-work)). The reputation requirement helps protect this question from spam and non-answer activity. Start asking to get answers Find the answer to your question by asking. [Ask question](https://cs.stackexchange.com/questions/ask) Explore related questions - [natural-language-processing](https://cs.stackexchange.com/questions/tagged/natural-language-processing "show questions tagged 'natural-language-processing'") See similar questions with these tags. - Featured on Meta - [All users on Stack Exchange can now participate in chat](https://meta.stackexchange.com/questions/417109/all-users-on-stack-exchange-can-now-participate-in-chat) - [Results of the January 2026 Community Asks Sprint: Community Badges](https://meta.stackexchange.com/questions/417043/results-of-the-january-2026-community-asks-sprint-community-badges) - [Community Engagement Across the Network: Focus for 2026](https://meta.stackexchange.com/questions/416985/community-engagement-across-the-network-focus-for-2026) #### Related [5](https://cs.stackexchange.com/questions/1079/when-did-commercial-speech-recognition-first-begin-using-grammar-sentence-struc "Question score (upvotes - downvotes)") [When did commercial Speech Recognition first begin using grammar (sentence structure) for prediction?](https://cs.stackexchange.com/questions/1079/when-did-commercial-speech-recognition-first-begin-using-grammar-sentence-struc) [2](https://cs.stackexchange.com/questions/47502/computing-probability-of-sentence-using-n-grams "Question score (upvotes - downvotes)") [Computing probability of sentence using N-grams](https://cs.stackexchange.com/questions/47502/computing-probability-of-sentence-using-n-grams) [1](https://cs.stackexchange.com/questions/50896/how-to-detect-plurals-in-english-sentences "Question score (upvotes - downvotes)") [How to detect plurals in English sentences?](https://cs.stackexchange.com/questions/50896/how-to-detect-plurals-in-english-sentences) [0](https://cs.stackexchange.com/questions/113260/which-algorithm-for-predicting-the-next-words-based-on-previous-words-given-a "Question score (upvotes - downvotes)") [Which algorithm for predicting the next word(s) based on previous words, given a sentence?](https://cs.stackexchange.com/questions/113260/which-algorithm-for-predicting-the-next-words-based-on-previous-words-given-a) [0](https://cs.stackexchange.com/questions/130434/sentiment-analysis-by-sentence-similarity "Question score (upvotes - downvotes)") [sentiment analysis by sentence similarity](https://cs.stackexchange.com/questions/130434/sentiment-analysis-by-sentence-similarity) #### [Hot Network Questions](https://stackexchange.com/questions?tab=hot) - [What's the electric flux through the base of a uniformly charged hemisphere due to its own electric field?](https://physics.stackexchange.com/questions/868894/whats-the-electric-flux-through-the-base-of-a-uniformly-charged-hemisphere-due) - [What would it mean for the name "Sartre" to be prophetic?](https://literature.stackexchange.com/questions/31502/what-would-it-mean-for-the-name-sartre-to-be-prophetic) - [YouTube Downloader implementation using CustomTkinter and Pytubefix](https://codereview.stackexchange.com/questions/301251/youtube-downloader-implementation-using-customtkinter-and-pytubefix) - [Lost in a Desolate Hypercube](https://puzzling.stackexchange.com/questions/136984/lost-in-a-desolate-hypercube) - [A finite type artinian algebra over a field is reduced if (and only if?) its module of differential is zero](https://math.stackexchange.com/questions/5123580/a-finite-type-artinian-algebra-over-a-field-is-reduced-if-and-only-if-its-mod) - [“All fantasy gaming worlds exist within the Material Plane” — wait, what?](https://rpg.stackexchange.com/questions/218719/all-fantasy-gaming-worlds-exist-within-the-material-plane-wait-what) - [Making a Displaced Logo Visible on Glass in Blender (Cycles)](https://blender.stackexchange.com/questions/345024/making-a-displaced-logo-visible-on-glass-in-blender-cycles) - [Does proof theoretic semantics overcome Tarski Undefinability?](https://philosophy.stackexchange.com/questions/135988/does-proof-theoretic-semantics-overcome-tarski-undefinability) - [Is the dual of a submultiplicative norm also submultiplicative?](https://math.stackexchange.com/questions/5123553/is-the-dual-of-a-submultiplicative-norm-also-submultiplicative) - [Acts 26:5 ( KJV) : Why the double Superlatives?](https://hermeneutics.stackexchange.com/questions/114617/acts-265-kjv-why-the-double-superlatives) - [Rationale of variadicity of std::function\_ref](https://stackoverflow.com/questions/79884343/rationale-of-variadicity-of-stdfunction-ref) - [If I pack a lunch at 9am and eat it at noon, isn't it in the danger zone for three hours? How is it safe?](https://cooking.stackexchange.com/questions/136687/if-i-pack-a-lunch-at-9am-and-eat-it-at-noon-isnt-it-in-the-danger-zone-for-thr) - [What's wrong with "He has started the task since June"?](https://ell.stackexchange.com/questions/373893/whats-wrong-with-he-has-started-the-task-since-june) - [Group text chat without computers](https://worldbuilding.stackexchange.com/questions/272579/group-text-chat-without-computers) - [can't get C-S-\<print\> or C-\<print\> to emacs -nw in xterm](https://emacs.stackexchange.com/questions/85461/cant-get-c-s-print-or-c-print-to-emacs-nw-in-xterm) - [How to create forecasts from a model](https://stats.stackexchange.com/questions/674681/how-to-create-forecasts-from-a-model) - [“Internal Error” on JMLR resubmission page](https://academia.stackexchange.com/questions/225861/internal-error-on-jmlr-resubmission-page) - [Why is momentum used instead of force when analyzing collisions?](https://physics.stackexchange.com/questions/868820/why-is-momentum-used-instead-of-force-when-analyzing-collisions) - [On arithmetically recursible Harrison order](https://mathoverflow.net/questions/507843/on-arithmetically-recursible-harrison-order) - [Novel about a non-sentient giant that walks towards the narrator, set in UK](https://scifi.stackexchange.com/questions/303164/novel-about-a-non-sentient-giant-that-walks-towards-the-narrator-set-in-uk) - [Did Donald Trump post a video portraying Barack and Michelle Obama as monkeys?](https://skeptics.stackexchange.com/questions/60464/did-donald-trump-post-a-video-portraying-barack-and-michelle-obama-as-monkeys) - [Do you think about math in words or images, or is it more chaotic, and feelings-based, and is it more a conscious or subconscious activity for you?](https://mathoverflow.net/questions/507913/do-you-think-about-math-in-words-or-images-or-is-it-more-chaotic-and-feelings) - [Identify fantasy novel (1970s–1980s): rival male/female wizards, demon in artificial knight body, child becomes apprentice](https://scifi.stackexchange.com/questions/303159/identify-fantasy-novel-1970s-1980s-rival-male-female-wizards-demon-in-artifi) - [What would be required to give human like intelligence to rats?](https://worldbuilding.stackexchange.com/questions/272584/what-would-be-required-to-give-human-like-intelligence-to-rats) [more hot questions](https://cs.stackexchange.com/questions/35951/detect-if-a-sentence-is-in-passive-voice) [Question feed](https://cs.stackexchange.com/feeds/question/35951 "Feed of this question and its answers") # Subscribe to RSS Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader. ![](https://cs.stackexchange.com/posts/35951/ivc/cac1?prg=2b3078b2-17cf-48c6-b5f5-eb423a9f4eaf) ##### [Computer Science](https://cs.stackexchange.com/) - [Tour](https://cs.stackexchange.com/tour) - [Help](https://cs.stackexchange.com/help) - [Chat](https://chat.stackexchange.com/?tab=site&host=cs.stackexchange.com) - [Contact](https://cs.stackexchange.com/contact) - [Feedback](https://cs.meta.stackexchange.com/) ##### [Company](https://stackoverflow.co/) - [Stack Overflow](https://stackoverflow.com/) - [Stack Internal](https://stackoverflow.co/internal/) - [Stack Data Licensing](https://stackoverflow.co/data-licensing/) - [Stack Ads](https://stackoverflow.co/advertising/) - [About](https://stackoverflow.co/) - [Press](https://stackoverflow.co/company/press/) - [Legal](https://stackoverflow.com/legal) - [Privacy Policy](https://stackoverflow.com/legal/privacy-policy) - [Terms of Service](https://stackoverflow.com/legal/terms-of-service/public) - Cookie Settings - [Cookie Policy](https://policies.stackoverflow.co/stack-overflow/cookie-policy) ##### [Stack Exchange Network](https://stackexchange.com/) - [Technology](https://stackexchange.com/sites#technology) - [Culture & recreation](https://stackexchange.com/sites#culturerecreation) - [Life & arts](https://stackexchange.com/sites#lifearts) - [Science](https://stackexchange.com/sites#science) - [Professional](https://stackexchange.com/sites#professional) - [Business](https://stackexchange.com/sites#business) - [API](https://api.stackexchange.com/) - [Data](https://data.stackexchange.com/) - [Blog](https://stackoverflow.blog/?blb=1) - [Facebook](https://www.facebook.com/officialstackoverflow/) - [Twitter](https://twitter.com/stackoverflow) - [LinkedIn](https://linkedin.com/company/stack-overflow) - [Instagram](https://www.instagram.com/thestackoverflow) Site design / logo © 2026 Stack Exchange Inc; user contributions licensed under [CC BY-SA](https://stackoverflow.com/help/licensing) . rev 2026.2.6.39523
Readable Markdown
Given an English sentence, I am looking for a programmatic way to tell whether the sentence is written in passive voice. Currently, I just check if there is a `was` or `were` inside the sentence. If yes, then the function will say that the sentence is in passive voice (I do no not know even if this is true). Is there a better approach? *** I just want to make a *simple* detector for passive voice, I do not care much for accuracy and efficiency. Here what I ended up with: ``` // http://english.stackexchange.com/questions/472/how-can-i-reliably-and-accurately-identify-the-passive-voice-in-writing-or-speec // forms of be, have and get int auxilary_verb(char* str) { if(strstr(str, "be ") || strstr(str, "been ") || strstr(str, "being ") || strstr(str, "have ") || strstr(str, "had ") || strstr(str, "was ") || strstr(str, "were ") || strstr(str, "wasn") || strstr(str, "weren") || strstr(str, "got ") || strstr(str, "get ") || strstr(str, "getting ")) { return 1; } else { return 0; } } // past participles of the verbs here http://web2.uvcs.uvic.ca/elc/sample/beginner/gs/gs_10.htm int past_participle_transitive_verb(char* str) { if(strstr(str, "brought ") || strstr(str, "cost ") || strstr(str, "given ") || strstr(str, "lent ") || strstr(str, "offered ") || strstr(str, "passed ") || strstr(str, "played ") || strstr(str, "read ") || strstr(str, "sent ") || strstr(str, "sung ") || strstr(str, "sent ") || strstr(str, "taught ") || strstr(str, "written ") || strstr(str, "bought ") || strstr(str, "get done ") || strstr(str, "left ") || strstr(str, "made ") || strstr(str, "owed ") || strstr(str, "paid ") || strstr(str, "promised ") || strstr(str, "refused ") || strstr(str, "shown ") || strstr(str, "taken ") || strstr(str, "told ") ) { return 1; } else { return 0; } } // Once a week, the house is cleaned by Tom. <- passive // By the end of the week, I'll be gone. <- not passive, but ok. int contains_by(char* str) { return (strstr(str, "by ") != NULL); } // how to find No direct object -> I don't know. // The subject of the verb phrase is the entity undergoing an action or having its state changed -> I don't know. int passive_voice(char* str) { // relax conditions, by applying || isntead of && if(auxilary_verb(str) || past_participle_transitive_verb(str) || contains_by(str)) { return 1; } else { return 0; } } ```
Shard18 (laksa)
Root Hash8045678284012640218
Unparsed URLcom,stackexchange!cs,/questions/35951/detect-if-a-sentence-is-in-passive-voice s443