This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Data model generator based on gen_data.txt | |
*/ | |
public void makeDataTrainingModel() { | |
model = null; | |
System.out.println("POS model started"); | |
InputStream dataIn = null; | |
try { | |
String currentDir = new File("").getAbsolutePath(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ArrayList textAnalisis(String inputdata){ | |
System.out.println("-> Nimbler: RestController: current message:\n " + inputdata); | |
/** | |
* Detector of sentence and divide text on independent sentence. | |
*/ | |
String[] sentences = sentenceDetect(inputdata); | |
System.out.println(Arrays.toString(sentences)); | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void makeDataTrainingModel() { | |
model = null; | |
System.out.println("POS model started"); | |
// InputStream dataIn = null; | |
InputStreamFactory dataIn = null; | |
try { | |
final String currentDir = new File("").getAbsolutePath(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String[] sentenceDetect(String message) { | |
System.out.println("-> OpenNLP: sentence detector"); | |
return sentenceDetector.sentDetect(message); | |
} | |
public String[] tokenize(String message) { | |
System.out.println("-> OpenNLP: token detector"); | |
return tokenizer.tokenize(message); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
public class NlpProductClassifier { | |
public static void main(String[] args) throws IOException { | |
NLPClassifier CL = new NLPClassifier(); | |
/** | |
* Sentence detector test | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Naive Bayes | |
*/ | |
import weka.classifiers.bayes.NaiveBayesMultinomial; | |
/** | |
* Weka tools | |
*/ | |
import weka.classifiers.Evaluation; | |
import weka.classifiers.meta.FilteredClassifier; | |
import weka.core.Attribute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DebitCreditWekaClassifier() { | |
/* | |
* Class for running an arbitrary classifier on data that has been passed through an arbitrary filter. | |
*/ | |
classifier = new FilteredClassifier(); | |
/** | |
* Class for building and using a multinomial Naive Bayes classifier. For more information see, | |
* Andrew Mccallum, Kamal Nigam: A Comparison of Event Models for Naive Bayes Text Classification. | |
* https://weka.sourceforge.io/doc.dev/weka/classifiers/bayes/NaiveBayesMultinomial.html | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Logger LOGGER = Logger.getLogger("DebitCreditInternalSystem"); | |
private FilteredClassifier classifier; | |
/** | |
* Declare train and test data Instances | |
*/ | |
private Instances trainData; | |
/** | |
* Declare Instance's attributes | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* load training data and set feature generators | |
*/ | |
public void transform() { | |
try { | |
trainData = loadDataset(TRAIN_DATA); | |
saveArff(trainData, TRAIN_ARFF_ARFF); | |
/** | |
* create the filter and set the attribute to be transformed from text into a feature vector (the last one) | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Build prepared classifier on the training data | |
*/ | |
public void fit() { | |
try { | |
classifier.buildClassifier(trainData); | |
} catch (Exception e) { | |
LOGGER.warning(e.getMessage()); | |
} | |
} |
OlderNewer