updated usage

This commit is contained in:
jarbasal 2018-05-01 22:04:24 +01:00
parent 18202c124a
commit 6f9048f792
3 changed files with 72 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@ -280,7 +280,27 @@ class PsychonautWiki(object):
self.substance_list = self.get_substance_list()
self.substances = self.get_substance_data()
def fix_substance_names(self, sentence):
# check for drug slang names
for substance in self.drug_slang:
name = self.drug_slang[substance].strip()
if substance.lower() in sentence.split(" "):
return sentence.replace(substance.lower(), name)
# check substance list
for substance in self.substance_list:
if substance.lower() in sentence.split(" "):
return sentence.replace(substance.lower(), substance)
# probably not talking about drugs
return False
def search_psychonaut_wiki(self, substance):
s = self.fix_substance_names(substance)
if not s:
print "Warning, this query does not seem to contain a valid substance name"
else:
substance = s
# match case, psychonaut wiki doesn't like lower-case
subs = self.substance_list
substances = [s.lower() for s in subs]
@ -401,9 +421,9 @@ class AskTheCaterpillar(object):
def __init__(self):
self.substance_list = PsychonautWiki.get_substance_list()
def is_about_drugs(self, sentence):
def fix_substance_names(self, sentence):
# check for drug slang names
# check for drug slanslangg names
for substance in self.drug_slang:
name = self.drug_slang[substance].strip()
if substance.lower() in sentence.split(" "):

View File

@ -2,7 +2,7 @@ from setuptools import setup
setup(
name='PySychonaut',
version='0.2',
version='0.3',
packages=['pysychonaut'],
url='https://github.com/JarbasAl/PySychonaut',
license='MIT',