Open ankita240796 opened 6 years ago
One possible approach would be to use NLTK to look for verbs.
It is probably the case that a list is a procedure if every (or most) bullet points begin with a verb in the base or singular non-3rd present (VB
or VBP
in NLTK terms).
@adammichaelwood I tested NLTK with the following code to check for ordered list.
def check_list(text):
"""Find and check ordered lists."""
regex = r'(\d+\.\s.*\n?)+'
ordlist = []
for m in re.finditer(regex, text):
ordlist += [(m.group(0),m.start()+1)]
length = len(ordlist)
index = 0
while index < length:
ol = []
ele = ordlist[index]
item = ele[0]
start = ele[1]
(row, col) = line_and_column(text, start)
ol.append(item)
index += 1
while index < length:
ele = ordlist[index]
item = ele[0]
if item.startswith("1. "):
break
ol.append(item)
index += 1
for point in ol:
tokens = nltk.word_tokenize(point)
tagged = nltk.pos_tag(tokens)
print(tagged)
The problem is that with a list like this one, the tags returned for first words are: NNP or NN instead of VB or VBP.
1. Click on :guilabel:`Apps` button at the bottom of the screen.
.. image:: /img/collect-best-practices/apps.png
:alt: Image showing Apps button.
:class: device-screen-vertical
2. :gesture:`Touch and hold` on an empty space on the Home screen and then click on :guilabel:`Widgets` button at the bottom of the screen.
.. image:: /img/collect-best-practices/widgets.png
:alt: Image showing Widgets button.
:class: device-screen-vertical
3. Find the :guilabel:`ODK Form` widget and then :gesture:`touch and hold` it.
.. image:: /img/collect-best-practices/odk-form.png
:alt: Image showing ODK Form widget.
:class: device-screen-vertical
4. A menu pops up listing all the available forms. Select the form you wish to create a shortcut for.
.. image:: /img/collect-best-practices/form-list.png
:alt: Image showing form list.
:class: device-screen-vertical
5. Shortcut for the selected form will appear on your home screen. You can move the shortcut to the desired position by :gesture:`drag and drop`.
.. image:: /img/collect-best-practices/form-shortcut.png
:alt: Image showing form shortcut.
:class: device-screen-vertical
Result is quite diverese for various lists. So, in many cases false warnings will be shown. I am not sure about how to proceed. Any suggestions on this?
In reference to #94, #427. What approaches can we take to implement testing for ordered list and unordered list in style-guide testing?