Skip to content

Commit 90bc968

Browse files
committed
added words_cont doc
1 parent f2931a7 commit 90bc968

File tree

7 files changed

+47
-1
lines changed

7 files changed

+47
-1
lines changed
113 Bytes
Binary file not shown.

docs/_build/doctrees/index.doctree

4.4 KB
Binary file not shown.

docs/_build/html/genindex.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ <h1 id="index">Index</h1>
115115
| <a href="#R"><strong>R</strong></a>
116116
| <a href="#S"><strong>S</strong></a>
117117
| <a href="#U"><strong>U</strong></a>
118+
| <a href="#W"><strong>W</strong></a>
118119

119120
</div>
120121
<h2 id="C">C</h2>
@@ -208,6 +209,16 @@ <h2 id="U">U</h2>
208209
<dt><a href="index.html#string_utils.uuid">uuid() (in module string_utils)</a>
209210
</dt>
210211

212+
</dl></td>
213+
</tr></table>
214+
215+
<h2 id="W">W</h2>
216+
<table style="width: 100%" class="indextable genindextable"><tr>
217+
<td style="width: 33%" valign="top"><dl>
218+
219+
<dt><a href="index.html#string_utils.words_count">words_count() (in module string_utils)</a>
220+
</dt>
221+
211222
</dl></td>
212223
</tr></table>
213224

docs/_build/html/index.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,28 @@ <h1>Welcome to Python String Utils&#8217;s documentation!<a class="headerlink" h
329329
</table>
330330
</dd></dl>
331331

332+
<dl class="function">
333+
<dt id="string_utils.words_count">
334+
<code class="descclassname">string_utils.</code><code class="descname">words_count</code><span class="sig-paren">(</span><em>string</em><span class="sig-paren">)</span><a class="headerlink" href="#string_utils.words_count" title="Permalink to this definition"></a></dt>
335+
<dd><p>Returns the number of words contained into the given string.</p>
336+
<p>This method is smart, it does consider only sequence of one or more letter and/or numbers
337+
as &#8220;words&#8221;, so a string like this: &#8221;! &#64; # % ... []&#8221; will return zero!
338+
Moreover it is aware of punctuation, so the count for a string like &#8220;one,two,three.stop&#8221;
339+
will be 4 not 1 (even if there are no spaces in the string).</p>
340+
<table class="docutils field-list" frame="void" rules="none">
341+
<col class="field-name" />
342+
<col class="field-body" />
343+
<tbody valign="top">
344+
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>string</strong> (<em>str</em>) &#8211; String to check.</td>
345+
</tr>
346+
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Number of words.</td>
347+
</tr>
348+
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">int</td>
349+
</tr>
350+
</tbody>
351+
</table>
352+
</dd></dl>
353+
332354
<dl class="function">
333355
<dt id="string_utils.camel_case_to_snake">
334356
<code class="descclassname">string_utils.</code><code class="descname">camel_case_to_snake</code><span class="sig-paren">(</span><em>string</em>, <em>separator='_'</em><span class="sig-paren">)</span><a class="headerlink" href="#string_utils.camel_case_to_snake" title="Permalink to this definition"></a></dt>

docs/_build/html/objects.inv

5 Bytes
Binary file not shown.

docs/_build/html/searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

string_utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,19 @@ def is_ip(string):
259259

260260

261261
def words_count(string):
262+
"""
263+
Returns the number of words contained into the given string.
264+
265+
This method is smart, it does consider only sequence of one or more letter and/or numbers
266+
as "words", so a string like this: "! @ # % ... []" will return zero!
267+
Moreover it is aware of punctuation, so the count for a string like "one,two,three.stop"
268+
will be 4 not 1 (even if there are no spaces in the string).
269+
270+
:param string: String to check.
271+
:type string: str
272+
:return: Number of words.
273+
:rtype: int
274+
"""
262275
return len(WORDS_COUNT_RE.findall(string))
263276

264277

0 commit comments

Comments
 (0)