So, I have this shell script:
echo "Enter text to be classified, hit return to run classification." read text if [ `echo "$text" | sed -r 's/ +/ /g' | bin/stupidfilter data/c_rbf` = "1.000000" ] then echo "Text is not likely to be stupid." fi if [ `echo "$text" | sed -r 's/ +/ /g' | bin/stupidfilter data/c_rbf` = "0.000000" ] then echo "Text is likely to be stupid." fi
I would like to write it in python. How to do it?
(As you can see, it uses the library http://stupidfilter.org/stupidfilter-0.2-1.tar.gz )
To do this just like a shell script does:
import subprocess text = raw_input("Enter text to be classified: ") p1 = subprocess.Popen('bin/stupidfilter', 'data/c_trbf') stupid = float(p1.communicate(text)[0]) if stupid: print "Text is likely to be stupid" else: print "Text is not likely to be stupid"
You can clearly execute commands as sub-shells and read the return value, as in a shell script, and then process the result in Python.
This is easier than loading C. functions.
stupidfilter, , - . , , - Python C.
stupidfilter
- , .
Source: https://habr.com/ru/post/1711043/More articles:.NET pie chart: how to add text to slicers and rotate a graph - c #command line tool to change sound - audioWhy does asp: ContentPlaceHolder in the title replace the whole title? - asp.net-mvcУ меня есть данные с кодировкой latin1, находящиеся в базе данных mysql UTF-8, как я могу это исправить? - phpHow can I make rdoc correctly read method arguments from my c extension? - c ++How to extract a string from a larger string? - javascriptReport syntax errors in a JSON object with jQuery and / or Javascript - jsonHow do you add a JBoss EJB dependency with the created WebService? - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1711047/building-a-java-based-stock-trading-application-need-pointers-for-technologies-to-use&usg=ALkJrhgsufizhaK2G9MAL36vmCONKB3RHAWhat do I need to send text messages using Kannel? - phpAll Articles