The naive way:
sents = text.split('.')
avg_len = sum(len(x.split()) for x in sents) / len(sents)
The serious way: use nltk to tokenize the text according to the target language rules.
More Related Contents:
- How to remove English words from a file containing Dari words?
- How to change 000-000 to 000000 in Python? [duplicate]
- Extract email id from text file by showing path
- Python 2: Conditional statement behaviour of lists with greater/smaller [duplicate]
- Zip lists in Python
- Insert an element at a specific index in a list and return the updated list
- Backporting Python 3 open(encoding=”utf-8″) to Python 2
- How to update the image of a Tkinter Label widget?
- 2D list has weird behavor when trying to modify a single value [duplicate]
- Accessing attributes on literals work on all types, but not `int`; why? [duplicate]
- python how to decode http response
- What is the Python ‘buffer’ type for?
- Fastest way to process a large file?
- How to integrate Pygame and PyQt4?
- UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-5: ordinal not in range(128) [duplicate]
- Can’t install mysql-python (newer versions) in Windows
- python re.sub, only replace part of match [duplicate]
- Printing on the same line with time.sleep()
- Module imports and __init__.py
- python_2_unicode_compatible error
- What does backward-slash b do in Python?
- ‘frozenset’ object is not callable
- How to filter a DataFrame column of lists for those that contain a certain item
- Get data from Twitter using Tweepy and store in csv file
- Run process with realtime output to a Tkinter GUI
- How to display charts in Spyder
- The ‘pip==7.1.0’ distribution was not found and is required by the application
- What does the slice() function do in Python?
- Any way to get one process to have a write lock and others to just read on parallel?
- Google Search Web Scraping with Python