def retrieveData(self, id, dataset): query = self.api.getDataQuery(id, dataset) iquery = InstanceQuery() iquery.db_url = "jdbc:mysql://" + self.config.HOST + ":" + str(self.config.PORT) + "/" + self.config.DB iquery.user = self.config.USER iquery.password = self.config.PASS iquery.query = query data = iquery.retrieve_instances() data.class_is_last() return data
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ iquery = InstanceQuery() iquery.db_url = str(self.resolve_option("db_url")) iquery.user = str(self.resolve_option("user")) iquery.password = str(self.resolve_option("password")) props = str(self.resolve_option("custom_props")) if (len(props) > 0) and os.path.isfile(props): iquery.custom_properties = props iquery.query = str(self.resolve_option("query")) data = iquery.retrieve_instances() self._output.append(Token(data)) return None
def main(): """ Just runs some example code. NB: You have to fill in the following parameters to make it work with MySQL: - HOSTNAME: the database server IP or hostname (or just 'localhost') - DBNAME: the name of the database to connect to - DBUSER: the user for connecting to the database - DBPW: the password for the database user - TABLE: the table to retrieve the data from And also supply the correct path to the MySQL jar in the "main" method below. """ # retrieve some data helper.print_title("Loading data from a database") iquery = InstanceQuery() iquery.db_url = "jdbc:mysql://HOSTNAME:3306/DBNAME" iquery.user = "******" iquery.password = "******" iquery.query = "select * from TABLE" data = iquery.retrieve_instances() print(data)
from weka.classifiers import Classifier from weka.core.converters import Loader from weka.core.database import InstanceQuery import weka.core.jvm as jvm from weka.core.stemmers import Stemmer from weka.core.stopwords import Stopwords from weka.core.tokenizers import Tokenizer from weka.filters import StringToWordVector, Filter try: jvm.start( class_path=["C:/Users/Esteb/Desktop/db/mongodb_unityjdbc_full.jar"]) iquery = InstanceQuery() iquery.db_url = "jdbc:mongo://localhost:27017/Grupo09" iquery.query = "select text from tweets;" data = iquery.retrieve_instances() #data.attribute_by_name('text').values = print(data) loader = Loader(classname="weka.core.converters.ArffLoader") iris_inc = loader.load_file("C:/Users/Esteb/Desktop/prueba.arff") iris_inc.class_is_last() #nom2str = Filter(classname=("weka.filters.unsupervised.attribute.StringToNominal"), options=["-R", "2-last"]) #nom2str.inputformat(data) #filtered1 = nom2str.filter(data) stemmer = Stemmer(classname="weka.core.stemmers.IteratedLovinsStemmer") stopwords = Stopwords(classname="weka.core.stopwords.Rainbow")