mirror of
https://github.com/OpenJarbas/PySychonaut.git
synced 2024-11-22 11:19:24 +01:00
updated usage
This commit is contained in:
parent
18202c124a
commit
6f9048f792
50
example.py
50
example.py
File diff suppressed because one or more lines are too long
@ -280,7 +280,27 @@ class PsychonautWiki(object):
|
|||||||
self.substance_list = self.get_substance_list()
|
self.substance_list = self.get_substance_list()
|
||||||
self.substances = self.get_substance_data()
|
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):
|
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
|
# match case, psychonaut wiki doesn't like lower-case
|
||||||
subs = self.substance_list
|
subs = self.substance_list
|
||||||
substances = [s.lower() for s in subs]
|
substances = [s.lower() for s in subs]
|
||||||
@ -401,9 +421,9 @@ class AskTheCaterpillar(object):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.substance_list = PsychonautWiki.get_substance_list()
|
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:
|
for substance in self.drug_slang:
|
||||||
name = self.drug_slang[substance].strip()
|
name = self.drug_slang[substance].strip()
|
||||||
if substance.lower() in sentence.split(" "):
|
if substance.lower() in sentence.split(" "):
|
||||||
|
2
setup.py
2
setup.py
@ -2,7 +2,7 @@ from setuptools import setup
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='PySychonaut',
|
name='PySychonaut',
|
||||||
version='0.2',
|
version='0.3',
|
||||||
packages=['pysychonaut'],
|
packages=['pysychonaut'],
|
||||||
url='https://github.com/JarbasAl/PySychonaut',
|
url='https://github.com/JarbasAl/PySychonaut',
|
||||||
license='MIT',
|
license='MIT',
|
||||||
|
Loading…
Reference in New Issue
Block a user