diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5f38543 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/nbproject/* +/build/* +*.class +*.xml \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/dist/javadoc/Exeptions/EmptyArrayException.html b/dist/javadoc/Exeptions/EmptyArrayException.html new file mode 100644 index 0000000..4567ca4 --- /dev/null +++ b/dist/javadoc/Exeptions/EmptyArrayException.html @@ -0,0 +1,301 @@ + + + + + + +EmptyArrayException + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
Exeptions
+

Class EmptyArrayException

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/Exeptions/InconveninentShapeException.html b/dist/javadoc/Exeptions/InconveninentShapeException.html new file mode 100644 index 0000000..9461a6d --- /dev/null +++ b/dist/javadoc/Exeptions/InconveninentShapeException.html @@ -0,0 +1,301 @@ + + + + + + +InconveninentShapeException + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
Exeptions
+

Class InconveninentShapeException

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/Exeptions/ModelNotFittedException.html b/dist/javadoc/Exeptions/ModelNotFittedException.html new file mode 100644 index 0000000..b712f3e --- /dev/null +++ b/dist/javadoc/Exeptions/ModelNotFittedException.html @@ -0,0 +1,223 @@ + + + + + + +ModelNotFittedException + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
Exeptions
+

Class ModelNotFittedException

+
+
+ +
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/MachineLearning/Model/AbstractModel.html b/dist/javadoc/MachineLearning/Model/AbstractModel.html new file mode 100644 index 0000000..e64c1b6 --- /dev/null +++ b/dist/javadoc/MachineLearning/Model/AbstractModel.html @@ -0,0 +1,242 @@ + + + + + + +AbstractModel + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
MachineLearning.Model
+

Class AbstractModel

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/MachineLearning/Model/Boosting.html b/dist/javadoc/MachineLearning/Model/Boosting.html new file mode 100644 index 0000000..1a5a90f --- /dev/null +++ b/dist/javadoc/MachineLearning/Model/Boosting.html @@ -0,0 +1,243 @@ + + + + + + +Boosting + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
MachineLearning.Model
+

Class Boosting

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/MachineLearning/Model/KNeighbourhood.html b/dist/javadoc/MachineLearning/Model/KNeighbourhood.html new file mode 100644 index 0000000..9fb30f7 --- /dev/null +++ b/dist/javadoc/MachineLearning/Model/KNeighbourhood.html @@ -0,0 +1,247 @@ + + + + + + +KNeighbourhood + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
MachineLearning.Model
+

Class KNeighbourhood

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/MachineLearning/Model/LinearKernel.html b/dist/javadoc/MachineLearning/Model/LinearKernel.html new file mode 100644 index 0000000..44fee98 --- /dev/null +++ b/dist/javadoc/MachineLearning/Model/LinearKernel.html @@ -0,0 +1,248 @@ + + + + + + +LinearKernel + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
MachineLearning.Model
+

Class LinearKernel

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/MachineLearning/Model/NormalKernel.html b/dist/javadoc/MachineLearning/Model/NormalKernel.html new file mode 100644 index 0000000..fcc7bd7 --- /dev/null +++ b/dist/javadoc/MachineLearning/Model/NormalKernel.html @@ -0,0 +1,248 @@ + + + + + + +NormalKernel + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
MachineLearning.Model
+

Class NormalKernel

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/MachineLearning/Preprocessing/WordProcessor.html b/dist/javadoc/MachineLearning/Preprocessing/WordProcessor.html new file mode 100644 index 0000000..0a83117 --- /dev/null +++ b/dist/javadoc/MachineLearning/Preprocessing/WordProcessor.html @@ -0,0 +1,168 @@ + + + + + + +WordProcessor + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
MachineLearning.Preprocessing
+

Interface WordProcessor

+
+
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/Other/DAO.html b/dist/javadoc/Other/DAO.html new file mode 100644 index 0000000..208e1ea --- /dev/null +++ b/dist/javadoc/Other/DAO.html @@ -0,0 +1,168 @@ + + + + + + +DAO + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
Other
+

Interface DAO

+
+
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/Other/DAOImplementation.html b/dist/javadoc/Other/DAOImplementation.html new file mode 100644 index 0000000..32366f5 --- /dev/null +++ b/dist/javadoc/Other/DAOImplementation.html @@ -0,0 +1,238 @@ + + + + + + +DAOImplementation + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
Other
+

Class DAOImplementation

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/Other/MathService.html b/dist/javadoc/Other/MathService.html new file mode 100644 index 0000000..41a87de --- /dev/null +++ b/dist/javadoc/Other/MathService.html @@ -0,0 +1,350 @@ + + + + + + +MathService + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
Other
+

Class MathService

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/Other/ModelSelectionHibernateEntity.html b/dist/javadoc/Other/ModelSelectionHibernateEntity.html new file mode 100644 index 0000000..1b21656 --- /dev/null +++ b/dist/javadoc/Other/ModelSelectionHibernateEntity.html @@ -0,0 +1,238 @@ + + + + + + +ModelSelectionHibernateEntity + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
Other
+

Class ModelSelectionHibernateEntity

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/Other/MyOwnArrayList.html b/dist/javadoc/Other/MyOwnArrayList.html new file mode 100644 index 0000000..bdac46f --- /dev/null +++ b/dist/javadoc/Other/MyOwnArrayList.html @@ -0,0 +1,285 @@ + + + + + + +MyOwnArrayList + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
Other
+

Class MyOwnArrayList

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/WorkFiles/FileReader.html b/dist/javadoc/WorkFiles/FileReader.html new file mode 100644 index 0000000..da1f07f --- /dev/null +++ b/dist/javadoc/WorkFiles/FileReader.html @@ -0,0 +1,243 @@ + + + + + + +FileReader + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
WorkFiles
+

Class FileReader

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/WorkFiles/FileWorker.html b/dist/javadoc/WorkFiles/FileWorker.html new file mode 100644 index 0000000..7fd473e --- /dev/null +++ b/dist/javadoc/WorkFiles/FileWorker.html @@ -0,0 +1,172 @@ + + + + + + +FileWorker + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
WorkFiles
+

Interface FileWorker

+
+
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/WorkFiles/FileWriter.html b/dist/javadoc/WorkFiles/FileWriter.html new file mode 100644 index 0000000..68144fb --- /dev/null +++ b/dist/javadoc/WorkFiles/FileWriter.html @@ -0,0 +1,243 @@ + + + + + + +FileWriter + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
WorkFiles
+

Class FileWriter

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/result/machinelearning/Model/NaiveBayes.html b/dist/javadoc/result/machinelearning/Model/NaiveBayes.html new file mode 100644 index 0000000..a1c1c9f --- /dev/null +++ b/dist/javadoc/result/machinelearning/Model/NaiveBayes.html @@ -0,0 +1,391 @@ + + + + + + +NaiveBayes + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
result.machinelearning.Model
+

Class NaiveBayes

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/result/machinelearning/preprocessing/CountVectorizer.html b/dist/javadoc/result/machinelearning/preprocessing/CountVectorizer.html new file mode 100644 index 0000000..5df2d12 --- /dev/null +++ b/dist/javadoc/result/machinelearning/preprocessing/CountVectorizer.html @@ -0,0 +1,447 @@ + + + + + + +CountVectorizer + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
result.machinelearning.preprocessing
+

Class CountVectorizer

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/result/machinelearning/preprocessing/LogisticRegression.html b/dist/javadoc/result/machinelearning/preprocessing/LogisticRegression.html new file mode 100644 index 0000000..8c41de3 --- /dev/null +++ b/dist/javadoc/result/machinelearning/preprocessing/LogisticRegression.html @@ -0,0 +1,422 @@ + + + + + + +LogisticRegression + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
result.machinelearning.preprocessing
+

Class LogisticRegression

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/result/machinelearning/preprocessing/MlModel.html b/dist/javadoc/result/machinelearning/preprocessing/MlModel.html new file mode 100644 index 0000000..399e5de --- /dev/null +++ b/dist/javadoc/result/machinelearning/preprocessing/MlModel.html @@ -0,0 +1,291 @@ + + + + + + +MlModel + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
result.machinelearning.preprocessing
+

Interface MlModel

+
+
+
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/result/machinelearning/preprocessing/PorterStemmer.html b/dist/javadoc/result/machinelearning/preprocessing/PorterStemmer.html new file mode 100644 index 0000000..322c33c --- /dev/null +++ b/dist/javadoc/result/machinelearning/preprocessing/PorterStemmer.html @@ -0,0 +1,290 @@ + + + + + + +PorterStemmer + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
result.machinelearning.preprocessing
+

Class PorterStemmer

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/result/machinelearning/preprocessing/SequenceProcessor.html b/dist/javadoc/result/machinelearning/preprocessing/SequenceProcessor.html new file mode 100644 index 0000000..7d23e8d --- /dev/null +++ b/dist/javadoc/result/machinelearning/preprocessing/SequenceProcessor.html @@ -0,0 +1,265 @@ + + + + + + +SequenceProcessor + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
result.machinelearning.preprocessing
+

Interface SequenceProcessor

+
+
+
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/result/machinelearning/preprocessing/TfidfVectorizer.html b/dist/javadoc/result/machinelearning/preprocessing/TfidfVectorizer.html new file mode 100644 index 0000000..6813a2e --- /dev/null +++ b/dist/javadoc/result/machinelearning/preprocessing/TfidfVectorizer.html @@ -0,0 +1,333 @@ + + + + + + +TfidfVectorizer + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
result.machinelearning.preprocessing
+

Class TfidfVectorizer

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/result/machinelearning/preprocessing/TfldfVectorizer.html b/dist/javadoc/result/machinelearning/preprocessing/TfldfVectorizer.html new file mode 100644 index 0000000..8988857 --- /dev/null +++ b/dist/javadoc/result/machinelearning/preprocessing/TfldfVectorizer.html @@ -0,0 +1,243 @@ + + + + + + +TfldfVectorizer + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
result.machinelearning.preprocessing
+

Class TfldfVectorizer

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/result/machinelearning/preprocessing/Transformer.html b/dist/javadoc/result/machinelearning/preprocessing/Transformer.html new file mode 100644 index 0000000..36b8b02 --- /dev/null +++ b/dist/javadoc/result/machinelearning/preprocessing/Transformer.html @@ -0,0 +1,172 @@ + + + + + + +Transformer + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
result.machinelearning.preprocessing
+

Interface Transformer

+
+
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/ru/caf82/lectures/lecture04/ExceptionCatchingExample.html b/dist/javadoc/ru/caf82/lectures/lecture04/ExceptionCatchingExample.html new file mode 100644 index 0000000..be285f9 --- /dev/null +++ b/dist/javadoc/ru/caf82/lectures/lecture04/ExceptionCatchingExample.html @@ -0,0 +1,272 @@ + + + + + + +ExceptionCatchingExample + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
ru.caf82.lectures.lecture04
+

Class ExceptionCatchingExample

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/ru/caf82/lectures/lecture04/ExceptionCatchingIhExample.html b/dist/javadoc/ru/caf82/lectures/lecture04/ExceptionCatchingIhExample.html new file mode 100644 index 0000000..ff9b0a9 --- /dev/null +++ b/dist/javadoc/ru/caf82/lectures/lecture04/ExceptionCatchingIhExample.html @@ -0,0 +1,272 @@ + + + + + + +ExceptionCatchingIhExample + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
ru.caf82.lectures.lecture04
+

Class ExceptionCatchingIhExample

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/ru/caf82/lectures/lecture04/MyExceptionClassExample.html b/dist/javadoc/ru/caf82/lectures/lecture04/MyExceptionClassExample.html new file mode 100644 index 0000000..1a5f115 --- /dev/null +++ b/dist/javadoc/ru/caf82/lectures/lecture04/MyExceptionClassExample.html @@ -0,0 +1,334 @@ + + + + + + +MyExceptionClassExample + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
ru.caf82.lectures.lecture04
+

Class MyExceptionClassExample

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/ru/caf82/lectures/lecture04/StackTraceExample.html b/dist/javadoc/ru/caf82/lectures/lecture04/StackTraceExample.html new file mode 100644 index 0000000..08adc0c --- /dev/null +++ b/dist/javadoc/ru/caf82/lectures/lecture04/StackTraceExample.html @@ -0,0 +1,273 @@ + + + + + + +StackTraceExample + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
ru.caf82.lectures.lecture04
+

Class StackTraceExample

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/ru/caf82/lectures/lecture04/ThrowExample.NegException.html b/dist/javadoc/ru/caf82/lectures/lecture04/ThrowExample.NegException.html new file mode 100644 index 0000000..fcc854c --- /dev/null +++ b/dist/javadoc/ru/caf82/lectures/lecture04/ThrowExample.NegException.html @@ -0,0 +1,227 @@ + + + + + + +ThrowExample.NegException + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
ru.caf82.lectures.lecture04
+

Class ThrowExample.NegException

+
+
+ +
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/ru/caf82/lectures/lecture04/ThrowExample.html b/dist/javadoc/ru/caf82/lectures/lecture04/ThrowExample.html new file mode 100644 index 0000000..1462228 --- /dev/null +++ b/dist/javadoc/ru/caf82/lectures/lecture04/ThrowExample.html @@ -0,0 +1,313 @@ + + + + + + +ThrowExample + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
ru.caf82.lectures.lecture04
+

Class ThrowExample

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/dist/javadoc/ru/caf82/lectures/lecture04/WorkWithExceptions.html b/dist/javadoc/ru/caf82/lectures/lecture04/WorkWithExceptions.html new file mode 100644 index 0000000..0b04e86 --- /dev/null +++ b/dist/javadoc/ru/caf82/lectures/lecture04/WorkWithExceptions.html @@ -0,0 +1,278 @@ + + + + + + +WorkWithExceptions + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
ru.caf82.lectures.lecture04
+

Class WorkWithExceptions

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/manifest.mf b/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml new file mode 100644 index 0000000..6807a2b --- /dev/null +++ b/nbproject/private/private.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/CountVectorizer.java b/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/CountVectorizer.java deleted file mode 100644 index 7038ad8..0000000 --- a/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/CountVectorizer.java +++ /dev/null @@ -1,7 +0,0 @@ -package ru.caf82.result.machinelearning.preprocessing; - -/** - * Created by ilysko on 03.08.17. - */ -public class CountVectorizer implements SequenceProcessor, Transformer { -} diff --git a/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/PorterStemmer.java b/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/PorterStemmer.java deleted file mode 100644 index 02fcf81..0000000 --- a/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/PorterStemmer.java +++ /dev/null @@ -1,7 +0,0 @@ -package ru.caf82.result.machinelearning.preprocessing; - -/** - * Created by ilysko on 03.08.17. - */ -public class PorterStemmer implements Transformer, WordProcessor { -} diff --git a/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/SequenceProcessor.java b/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/SequenceProcessor.java deleted file mode 100644 index 65e46d9..0000000 --- a/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/SequenceProcessor.java +++ /dev/null @@ -1,7 +0,0 @@ -package ru.caf82.result.machinelearning.preprocessing; - -/** - * Created by ilysko on 03.08.17. - */ -public interface SequenceProcessor { -} diff --git a/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/TfidfVectorizer.java b/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/TfidfVectorizer.java deleted file mode 100644 index cf212ba..0000000 --- a/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/TfidfVectorizer.java +++ /dev/null @@ -1,7 +0,0 @@ -package ru.caf82.result.machinelearning.preprocessing; - -/** - * Created by ilysko on 03.08.17. - */ -public class TfidfVectorizer implements SequenceProcessor, Transformer { -} diff --git a/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/Transformer.java b/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/Transformer.java deleted file mode 100644 index b94b278..0000000 --- a/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/Transformer.java +++ /dev/null @@ -1,7 +0,0 @@ -package ru.caf82.result.machinelearning.preprocessing; - -/** - * Created by ilysko on 03.08.17. - */ -public interface Transformer { -} diff --git a/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/WordProcessor.java b/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/WordProcessor.java deleted file mode 100644 index db8ead1..0000000 --- a/result/src/main/java/ru/caf82/result/machinelearning/preprocessing/WordProcessor.java +++ /dev/null @@ -1,7 +0,0 @@ -package ru.caf82.result.machinelearning.preprocessing; - -/** - * Created by ilysko on 03.08.17. - */ -public interface WordProcessor { -} diff --git a/result/src/main/java/ru/caf82/result/workwithfiles/FileReader.java b/result/src/main/java/ru/caf82/result/workwithfiles/FileReader.java deleted file mode 100644 index 993dc1d..0000000 --- a/result/src/main/java/ru/caf82/result/workwithfiles/FileReader.java +++ /dev/null @@ -1,7 +0,0 @@ -package ru.caf82.result.workwithfiles; - -/** - * Created by ilysko on 03.08.17. - */ -public class FileReader implements FileWorker { -} diff --git a/result/src/main/java/ru/caf82/result/workwithfiles/FileWorker.java b/result/src/main/java/ru/caf82/result/workwithfiles/FileWorker.java deleted file mode 100644 index 9fe4f42..0000000 --- a/result/src/main/java/ru/caf82/result/workwithfiles/FileWorker.java +++ /dev/null @@ -1,7 +0,0 @@ -package ru.caf82.result.workwithfiles; - -/** - * Created by ilysko on 03.08.17. - */ -public interface FileWorker { -} diff --git a/result/src/main/java/ru/caf82/result/workwithfiles/FileWriter.java b/result/src/main/java/ru/caf82/result/workwithfiles/FileWriter.java deleted file mode 100644 index 3de089c..0000000 --- a/result/src/main/java/ru/caf82/result/workwithfiles/FileWriter.java +++ /dev/null @@ -1,7 +0,0 @@ -package ru.caf82.result.workwithfiles; - -/** - * Created by ilysko on 03.08.17. - */ -public class FileWriter implements FileWorker { -} diff --git a/src/LectureDB/Connector.java b/src/LectureDB/Connector.java new file mode 100644 index 0000000..3a4b739 --- /dev/null +++ b/src/LectureDB/Connector.java @@ -0,0 +1,32 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package LectureDB; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + +/** + * + * @author Danny + */ +public class Connector { + public Connection link() { + String Url ="jdbc:mysql://localhost:3306/axample_mask"; + String Name="root"; + String Password="12345"; + Connection cn = null; + try { + Class.forName("com.mysql.jdbc.Driver"); + System.out.println("Драйвер подключен"); + cn = DriverManager.getConnection(Url, Name, Password); + System.out.println("Соединение установлено"); + } catch (ClassNotFoundException | SQLException ex) { + System.out.println("Error: " + ex.getMessage()); + } + return cn; + } +} diff --git a/src/LectureDB/DAO.java b/src/LectureDB/DAO.java new file mode 100644 index 0000000..2bfcbea --- /dev/null +++ b/src/LectureDB/DAO.java @@ -0,0 +1,93 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package LectureDB; + +import static java.lang.System.exit; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +/** + * + * @author Danny + */ +public class DAO { + + Connection connection = new Connector().link(); + + public void show() throws SQLException { + Statement State = null;//Simple inquiry without argument + State = connection.createStatement(); + ResultSet res = State.executeQuery("Select user.id, user.Login, user.Age, password.LoginId ,password.password from user , password"); + while (res.next()) { + System.out.println("Номер в выборке #" + res.getRow() + + "\t Номер в базе #" + res.getInt("id") + + "\t" + res.getString("Login") + + "\t" + res.getString("Age") + + "\t" + res.getString("LoginId") + + "\t" + res.getString("password")); + } + } + + public void add(String login, int age, String password) throws SQLException { + Statement State = null; + State = connection.createStatement(); + State.execute("INSERT INTO user (`Login`,`Age`) values ('" + login + "','" + age + "')"); + ResultSet res = State.executeQuery("select max(id) from user"); + int maxid = 0; + if (res.next()) { + maxid = res.getInt("max(id)"); + } + State.execute("insert into password (`LoginId`,`Password`) values ('" + maxid + "','" + password + "')"); + } + + public void delete(int num) throws SQLException { + Statement State = null; + State = connection.createStatement(); + ResultSet res = State.executeQuery("select id from user where id=" + num); + int id = 0; + if (res.next()) { + id = res.getInt("id"); + } + State.execute("delete from user where id=" + num); + State.execute("delete from password where LoginId=" + num); + } + + public void check(String login, String password) throws SQLException { + Statement State = null; + State = connection.createStatement(); + ResultSet res = State.executeQuery("select Login from user where Login='" + login+"'"); + String log = null; + if (res.next()) { + log = res.getString("Login"); + } + if(log==null){ + System.out.println("Not exist"); + System.exit(0); + } + System.out.println(log); + res = State.executeQuery("select Password from password where Password='" + password+"'"); + log=null; + if (res.next()) { + log = res.getString("Password"); + } + if(log==null){ + System.out.println("Not exist"); + System.exit(0); + } + System.out.println(log); + res = State.executeQuery("select * from user, password where user.Login='"+login+"' and password.Password='"+password+"'"); + while (res.next()) { + System.out.println("Номер в выборке #" + res.getRow() + + "\t Номер в базе #" + res.getInt("id") + + "\t" + res.getString("Login") + + "\t" + res.getString("Age") + + "\t" + res.getString("LoginId") + + "\t" + res.getString("password")); + } + } +} diff --git a/src/LectureDB/Main.java b/src/LectureDB/Main.java new file mode 100644 index 0000000..30450e4 --- /dev/null +++ b/src/LectureDB/Main.java @@ -0,0 +1,22 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package LectureDB; + +import java.sql.SQLException; + +/** + * + * @author Danny + */ +public class Main { + public static void main(String[] args) throws SQLException{ + //new DAO().add("David", 64, "Goliaf"); + //new DAO().show(); + //new DAO().delete(3); + new DAO().check("Sinicin", "Rn5"); + //new DAO().show(); + } +} diff --git a/src/LectureDB/Password.java b/src/LectureDB/Password.java new file mode 100644 index 0000000..67a748e --- /dev/null +++ b/src/LectureDB/Password.java @@ -0,0 +1,41 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package LectureDB; + +/** + * + * @author Danny + */ +public class Password { + private int id; + private int loginId; + private String password; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getLoginId() { + return loginId; + } + + public void setLoginId(int loginId) { + this.loginId = loginId; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + +} diff --git a/src/LectureDB/User.java b/src/LectureDB/User.java new file mode 100644 index 0000000..a85b36c --- /dev/null +++ b/src/LectureDB/User.java @@ -0,0 +1,41 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package LectureDB; + +/** + * + * @author Danny + */ +public class User { + private int id; + private String Login; + private int Age; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getLogin() { + return Login; + } + + public void setLogin(String Login) { + this.Login = Login; + } + + public int getAge() { + return Age; + } + + public void setAge(int Age) { + this.Age = Age; + } + +} diff --git a/src/exceptions/EmptyArrayException.java b/src/exceptions/EmptyArrayException.java new file mode 100644 index 0000000..b95ae07 --- /dev/null +++ b/src/exceptions/EmptyArrayException.java @@ -0,0 +1,25 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package exceptions; + +/** + * + * @author User + */ +public class EmptyArrayException extends Exception{ + public EmptyArrayException(){ + super(); + } + public EmptyArrayException(String message){ + super(message); + } + public EmptyArrayException(String message, Throwable cause){ + super(message,cause); + } + public EmptyArrayException(Throwable cause){ + super(cause); + } +} diff --git a/src/exceptions/InconveninentShapeException.java b/src/exceptions/InconveninentShapeException.java new file mode 100644 index 0000000..f523b86 --- /dev/null +++ b/src/exceptions/InconveninentShapeException.java @@ -0,0 +1,25 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package exceptions; + +/** + * + * @author User + */ +public class InconveninentShapeException extends Exception{ + public InconveninentShapeException(){ + super(); + } + public InconveninentShapeException(String message){ + super(message); + } + public InconveninentShapeException(String message, Throwable cause){ + super(message, cause); + } + public InconveninentShapeException(Throwable cause){ + super(cause); + } +} diff --git a/src/exceptions/ModelNotFittedException.java b/src/exceptions/ModelNotFittedException.java new file mode 100644 index 0000000..84e3fc5 --- /dev/null +++ b/src/exceptions/ModelNotFittedException.java @@ -0,0 +1,26 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package exceptions; + +/** + * + * @author User + */ +public class ModelNotFittedException extends Exception { + ModelNotFittedException() { + super(); + } + ModelNotFittedException(String message) { + super(message); + } + ModelNotFittedException(Throwable cause) { + super(cause); + } + ModelNotFittedException(Throwable cause, String message) { + super(message); + } +} + diff --git a/src/other/A.java b/src/other/A.java new file mode 100644 index 0000000..239b6bb --- /dev/null +++ b/src/other/A.java @@ -0,0 +1,17 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package other; + +/** + * + * @author Danny + */ +public class A { + String lol; + int num=13; + @Ser + String field = "Hello"; +} diff --git a/src/other/B.java b/src/other/B.java new file mode 100644 index 0000000..b6b3589 --- /dev/null +++ b/src/other/B.java @@ -0,0 +1,34 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package other; + +import java.io.FileOutputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; + +/** + * + * @author Danny + */ +public class B implements Serializable{ + public void serialization(Class A){ + Class cl=A.class; + Field[] field=cl.getDeclaredFields(); + for(Field f:field){ + Ser ser=f.getAnnotation(Ser.class); + if(ser==null){ + try(ObjectOutputStream ois=new ObjectOutputStream(new FileOutputStream("PathToFile"))){ + ois.writeObject(f); + } + catch(Exception ex){ + ex.printStackTrace(); + } + } + } + } +} diff --git a/src/other/HomeWork.java b/src/other/HomeWork.java new file mode 100644 index 0000000..9c250cc --- /dev/null +++ b/src/other/HomeWork.java @@ -0,0 +1,61 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package other; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import result.machinelearning.preprocessing.LogisticRegression; + +/** + * + * @author Danny + */ +public class HomeWork { + public static void main(String[] args) throws IOException, FileNotFoundException, ClassNotFoundException{ + HomeWork nc=new HomeWork(); + nc.ReadFromFile("fgg"); + nc.saveMlModelToFile(); + nc.readFromFile(); + } + public void ReadFromFile(String filename) throws IOException { + File file =new File("C:\\users\\user\\desktop\\work\\DD.txt"); + FileReader fir=new FileReader(file); + if(!file.exists())System.out.println("File no exist"); + StringBuffer sb=new StringBuffer(); + try{ + BufferedReader br=new BufferedReader(fir); + String s; + while ((s = br.readLine()) != null) { + sb.append(s); + sb.append("\n"); + } + } + catch(Exception e){ + System.out.println(e); + } + System.out.println(sb); + } + public void saveMlModelToFile() throws FileNotFoundException, IOException{ + FileOutputStream file=new FileOutputStream("C:\\users\\user\\desktop\\work\\Save.dat"); + ObjectOutputStream os=new ObjectOutputStream(file); + LogisticRegression lr=new LogisticRegression(); + os.writeObject(lr); + os.close(); + } + public void readFromFile() throws FileNotFoundException, IOException, ClassNotFoundException{ + ObjectInputStream os=new ObjectInputStream(new FileInputStream("C:\\users\\user\\desktop\\work\\Save.dat")); + LogisticRegression lg=(LogisticRegression)os.readObject(); + double wes[]=lg.getWeights(); + for(double w:wes)System.out.println(w); + } +} diff --git a/src/other/MathService.java b/src/other/MathService.java new file mode 100644 index 0000000..3a27296 --- /dev/null +++ b/src/other/MathService.java @@ -0,0 +1,53 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package other; +import exceptions.EmptyArrayException; +import exceptions.InconveninentShapeException; + +/** + * + * @author User + */ +public class MathService { + public static double doProduct(double[] a, double[] b) throws InconveninentShapeException,EmptyArrayException{ + double result=0; + if(a.length!=b.length) throw new InconveninentShapeException("DoProduct: разные размеры массивов!"); + if(a.length==0 | b.length==0) throw new EmptyArrayException("DoProduct: пустые массивы!"); + for (int x=0;x implements Iterable { + + private Object[] ElementData; + + MyOwnArrayList() { + this(10); + } + + MyOwnArrayList(int i) { + if (i < 0) { + throw new IllegalArgumentException("Illegal Capacity: " + i); + } + this.ElementData = new Object[i]; + } + + public void add(Object ob) { + int i = 0; + for (i = 0; i < ElementData.length; i++) { + if (ElementData[i] == null) { + break; + } + } + if (i == ElementData.length) { + ensureCapacity(ElementData.length + 1); + } + ElementData[i] = ob; + } + + public int size() { + int length = ElementData.length; + return length; + } + + public int indexOf(Object ob) { + int index = 0; + for (int i = 0; i < ElementData.length; i++) { + if (ob.equals(ElementData[i])) { + return i; + } + } + return -1; + } + + public boolean contains(Object ob) { + return indexOf(ob) > 0; + } + + public void remove(int index) { + System.arraycopy(ElementData, index + 1, ElementData, index, ElementData.length - index - 1); + ElementData[ElementData.length - 1] = null; + Object[] NewElementData = new Object[ElementData.length - 1]; + System.arraycopy(ElementData, 0, NewElementData, 0, ElementData.length - 1); + ElementData = new Object[NewElementData.length]; + ElementData = NewElementData; + + } + + public void remove(Object ob) { + int index = 0; + for (int i = 0; i < ElementData.length; i++) { + if (ob.equals(ElementData[i])) { + index = i; + break; + } + } + remove(index); + } + + public void set(int index, Object ob) { + ElementData[index] = ob; + } + + public void clear() { + for (int i = 0; i < ElementData.length; i++) { + ElementData[i] = null; + } + ElementData = new Object[0]; + } + + private void ensureCapacity(int copacity) { + if (copacity - ElementData.length > 0) { + Object[] NewElementData = new Object[ElementData.length + 1]; + System.arraycopy(ElementData, 0, NewElementData, 0, ElementData.length); + ElementData = new Object[NewElementData.length]; + ElementData = NewElementData; + } + } + + /* + Для проверки методов + */ + public void showAll() { + for (Object x : ElementData) { + System.out.println("Element: " + x); + } + } + + @Override + public Iterator iterator() { + return new Iterator() { + int i = 0; + + @Override + public boolean hasNext() { + if(i implements Iterable { + + private int size; + private Entry head; + private Entry pred; + + @Override + public Iterator iterator() { + return new Iterator() { + Entry e = head; + + @Override + public boolean hasNext() { + return (e != null); + } + + @Override + public Object next() { + Object ob = e.element; + e = e.next; + return ob; + } + + }; + } + + private static class Entry { + + Object element; + Entry next; + Entry prev; + + Entry(E element) { + this.element = element; + } + } + + public void add(Object ob) { + Entry e = new Entry(ob); + if (size == 0) { + head = e; + //head.next=e; + //head.prev=e; + } else { + pred.next = e; + e.prev = pred; + } + pred = e; + //head.prev=e; + size++; + + } + + public boolean contains(Object ob) { + Entry e = head; + while (e.next != null) { + if (e.element.equals(ob)) { + return true; + } + e = e.next; + } + return false; + } + + public void remove(Object ob) { + Entry e = head; + size--; + do { + if (size == 0) { + head = null; + break; + } + if (e.element.equals(ob)) { + if (head.element.equals(ob)) { + poll(); + break; + } else if (e.next == null) { + e.prev.next = null; + break; + } else { + e.next.prev = e.prev; + e.prev.next = e.next; + break; + } + } + e = e.next; + } while (e != null); + } + + public void set(int index, Object ob) { + Entry e = head; + for (int i = 0; i < size; i++) { + if (i == index) { + e.element = ob; + } + e = e.next; + } + } + + public Object peek() { + return head.element; + } + + public void addAll(Object[] ob) { + for (Object x : ob) { + add(x); + } + } + + public Object poll() { + Entry e = head; + head = head.next; + head.prev = null; + return e.element; + } + + /* + Для проверки методов + */ + public void showAll() { + Entry e = head; + while (e.next != null) { + System.out.println(e.element); + e = e.next; + } + System.out.println(e.element); + } +} diff --git a/src/other/NewClass.java b/src/other/NewClass.java new file mode 100644 index 0000000..7f0b5ef --- /dev/null +++ b/src/other/NewClass.java @@ -0,0 +1,39 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package other; + +import java.util.Iterator; + + +/** + * + * @author Danny + */ +public class NewClass { + public static void main(String[] args){ + MyOwnLinkedList moar=new MyOwnLinkedList(); + //Iterator it=moar.iterator(); + moar.add("1"); + moar.add("2"); + moar.add("3"); + moar.add("4"); + moar.add("5"); + moar.add("6"); + moar.add("7"); + moar.add("8"); + moar.add("9"); + moar.add("10"); + moar.add("11"); + moar.add("12"); + moar.add("13"); + moar.add("14"); + moar.add("15"); + + //moar.showAll(); + Iterator it=moar.iterator(); + while(it.hasNext())System.out.println(it.next()); + } +} diff --git a/src/other/Ser.java b/src/other/Ser.java new file mode 100644 index 0000000..393a64b --- /dev/null +++ b/src/other/Ser.java @@ -0,0 +1,22 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package other; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * + * @author Danny + */ +@Target(value=ElementType.FIELD) +@Retention(value= RetentionPolicy.RUNTIME) +public @interface Ser { + //String name(); +} + diff --git a/src/result/machinelearning/model/AbstractModel.java b/src/result/machinelearning/model/AbstractModel.java new file mode 100644 index 0000000..4ed2fd3 --- /dev/null +++ b/src/result/machinelearning/model/AbstractModel.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.machinelearning.model; + +/** + * + * @author User + */ +public class AbstractModel { + +} diff --git a/src/result/machinelearning/model/Boosting.java b/src/result/machinelearning/model/Boosting.java new file mode 100644 index 0000000..e407ac0 --- /dev/null +++ b/src/result/machinelearning/model/Boosting.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.machinelearning.model; + +/** + * + * @author User + */ +public class Boosting extends AbstractModel{ + +} diff --git a/src/result/machinelearning/model/KNeighbourhood.java b/src/result/machinelearning/model/KNeighbourhood.java new file mode 100644 index 0000000..7d652f3 --- /dev/null +++ b/src/result/machinelearning/model/KNeighbourhood.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.machinelearning.model; + +/** + * + * @author User + */ +public class KNeighbourhood extends AbstractModel{ + +} diff --git a/src/result/machinelearning/model/LinearKernel.java b/src/result/machinelearning/model/LinearKernel.java new file mode 100644 index 0000000..3b7625a --- /dev/null +++ b/src/result/machinelearning/model/LinearKernel.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.machinelearning.model; + +/** + * + * @author User + */ +public class LinearKernel extends KNeighbourhood{ + +} diff --git a/src/result/machinelearning/model/NaiveBayes.java b/src/result/machinelearning/model/NaiveBayes.java new file mode 100644 index 0000000..5fe4126 --- /dev/null +++ b/src/result/machinelearning/model/NaiveBayes.java @@ -0,0 +1,109 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.machinelearning.model; + +import exceptions.InconveninentShapeException; +import exceptions.ModelNotFittedException; +import java.io.IOException; +import java.util.List; +import result.machinelearning.preprocessing.MlModel; + +/** + * + * @author User + */ +public class NaiveBayes implements MlModel { + private float alpha; + private double[][] weights; + private boolean fitted; + private boolean parallel; + public NaiveBayes(float alpha, boolean parallel) { + //Миша сказал забить + } + public MlModel train(double[][] X, int[] y) throws InconveninentShapeException { + //считаем у=0 и y=1 + if (X.length != y.length) + throw new InconveninentShapeException(); + double yZer = 0, yOne = 0; + for (int i=0; i> X, List y) throws InconveninentShapeException { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } +} + + diff --git a/src/result/machinelearning/model/NormalKernel.java b/src/result/machinelearning/model/NormalKernel.java new file mode 100644 index 0000000..895b653 --- /dev/null +++ b/src/result/machinelearning/model/NormalKernel.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.machinelearning.model; + +/** + * + * @author User + */ +public class NormalKernel extends KNeighbourhood{ + +} diff --git a/src/result/machinelearning/preprocessing/CountVectorizer.java b/src/result/machinelearning/preprocessing/CountVectorizer.java new file mode 100644 index 0000000..f71194d --- /dev/null +++ b/src/result/machinelearning/preprocessing/CountVectorizer.java @@ -0,0 +1,116 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.machinelearning.preprocessing; + +import java.util.*; + +/** + * + * @author 1 + */ +public class CountVectorizer { + private final Set setWordsFromAllTexts = new HashSet<>(); + private final List textClasses = new ArrayList<>(); + private final List listOfTexts = new ArrayList<>(); + private static List defaultStopWordsList = new ArrayList( + Arrays.asList(new String[]{ + "а","е","и","ж","м","о","на","не","ни","об","но","он","мне","мои","мож","она","они","оно", + "мной","много","многочисленное","многочисленная","многочисленные","многочисленный", + "мною","мой","мог","могут","можно","может","можно","мор","моя","моё","мочь","над","нее", + "оба","нам","нем","нами","ними","мимо","немного","одной","одного","менее","однажды","однако", + "меня","нему","меньше","ней","наверху","него","ниже","мало","надо","один","одиннадцать","одиннадцатый", + "назад","наиболее","недавно","миллионов","недалеко","между","низко","меля","нельзя","нибудь", + "непрерывно","наконец","никогда","никуда","нас","наш","нет","нею","неё","них","мира","наша", + "наше","наши","ничего","начала","нередко","несколько","обычно","опять","около","мы","ну","нх","от","отовсюду", + "особенно","нужно","очень","отсюда","в","во","вон","вниз","внизу","вокруг","вот","восемнадцать", + "восемнадцатый","восемь","восьмой","вверх","вам","вами","важное","важная","важные","важный","вдали","везде", + "ведь","вас","ваш","ваша","ваше","ваши","впрочем","весь","вдруг","вы","все","второй","всем","всеми","времени","время", + "всему","всего","всегда","всех","всею","всю","вся","всё","всюду","г","год","говорил","говорит","года","году","где", + "да","ее","за","из","ли","же","им","до","по","ими","под","иногда","довольно","именно","долго","позже", + "более","должно","пожалуйста","значит","иметь","больше","пока","ему","имя","пор","пора","потом","потому","после", + "почему","почти","посреди","ей","два","две","двенадцать","двенадцатый","двадцать","двадцатый", + "двух","его","дел","или","без","день","занят","занята","занято","заняты","действительно","давно", + "девятнадцать","девятнадцатый","девять","девятый","даже","алло","жизнь","далеко","близко","здесь","дальше","для", + "лет","зато","даром","первый","перед","затем","зачем","лишь","десять","десятый","ею","её","их","бы","еще","при", + "был","про","процентов","против","просто","бывает","бывь","если","люди","была","были","было","будем","будет","будете","будешь", + "прекрасно","буду","будь","будто","будут","ещё","пятнадцать","пятнадцатый","друго","другое","другой","другие","другая","других","есть","пять", + "быть","лучше","пятый","к","ком","конечно","кому","кого","когда","которой","которого","которая","которые","который","которых","кем", + "каждое","каждая","каждые","каждый","кажется","как","какой","какая","кто","кроме","куда","кругом","с","т","у","я", + "та","те","уж","со","то","том","снова","тому","совсем","того","тогда","тоже","собой","тобой","собою","тобою", + "сначала","только","уметь","тот","тою","хорошо","хотеть","хочешь","хоть","хотя","свое","свои","твой","своей","своего","своих", + "свою","твоя","твоё","раз","уже","сам","там","тем","чем","сама","сами","теми","само","рано","самом","самому", + "самой","самого","семнадцать","семнадцатый","самим","самими","самих","саму", + "семь","чему","раньше","сейчас","чего","сегодня","себе","тебе","сеаой","человек","разве","теперь","себя","тебя","седьмой","спасибо", + "слишком","так","такое","такой","такие","также","такая","сих","тех","чаще","четвертый","через","часто","шестой","шестнадцать","шестнадцатый", + "шесть","четыре","четырнадцать","четырнадцатый","сколько","сказал","сказала","сказать", + "ту","ты","три","эта","эти","что","это","чтоб","этом","этому","этой","этого","чтобы","этот","стал","туда", + "этим","этими","рядом","тринадцать","тринадцатый","этих","третий","тут","эту","суть","чуть","тысяч" + }) + ); + + + /** + * Метод извлекающий слова из переданного в метод текста. + * Не учитываются слова поля из + * @see CountVectorizer#defaultStopWordsList + * Используется класс + * @see PorterStemmer для стемминга + * @param text Текст, из которого извлекаются слова + * @return Список слов + */ + private static List preprocess(String text) { + text = text.toLowerCase().replaceAll("[^а-я -]","").replaceAll(" +-"," ").replaceAll("- +"," "); + String[] array = text.split(" +"); + for (int i = 0; i list = new ArrayList<>(Arrays.asList(array)); + list.removeAll(defaultStopWordsList); + return list; + } + + + public List> transform() { + List> listOfVectors = new ArrayList<>(); + for (String text : listOfTexts) { + listOfVectors.add(countWordsInText(preprocess(text))); + } + return listOfVectors; + } + + public CountVectorizer(Map mapOfTexts) { + listOfTexts.addAll(mapOfTexts.keySet()); + addWordsInSetFromTexts(mapOfTexts.keySet()); + textClasses.addAll(mapOfTexts.values()); + + } + + private List countWordsInText(List words) { + List vector = new ArrayList<>(); + for (String word : setWordsFromAllTexts) { + vector.add(Collections.frequency(words,word)); + } + return vector; + } + + private void addWordsInSetFromTexts(Set texts) { + for (String text : texts) { + setWordsFromAllTexts.addAll(preprocess(text)); + } + } + + public List getTextClasses() { + return textClasses; + } + + public List> appendTextsAndTransform(Map mapOfTexts) { + listOfTexts.addAll(mapOfTexts.keySet()); + addWordsInSetFromTexts(mapOfTexts.keySet()); + textClasses.addAll(mapOfTexts.values()); + return transform(); + } + +} \ No newline at end of file diff --git a/src/result/machinelearning/preprocessing/LogisticRegression.java b/src/result/machinelearning/preprocessing/LogisticRegression.java new file mode 100644 index 0000000..2809431 --- /dev/null +++ b/src/result/machinelearning/preprocessing/LogisticRegression.java @@ -0,0 +1,206 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.machinelearning.preprocessing; + +import exceptions.EmptyArrayException; +import exceptions.InconveninentShapeException; +import other.MathService; + +import java.io.*; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import other.NewClass; + +/** + * + * @author Danny + */ +public class LogisticRegression implements MlModel, Serializable { + + private static final long serialVersionUID = 5865555265285679275L; + private final int ITERATES = 1000; + private final double rate = 0.001; + private double[] weights = null; + + /** + * Adding first column with 1 + * @param X + * @return + */ + private List> init(List> X) { + for (int i = 0; i < X.size(); i++) { + X.get(i).add(0, 1); + } + return X; + } + + /** + * Change list of Integer to double array + * + * @param list + * @return + */ + private double[] toIntArray(List list) { + double[] intArray = new double[list.size()]; + for (int i = 0; i < list.size(); i++) { + intArray[i] = list.get(i); + } + return intArray; + } + + /** + * Change list of boolean to double array + * + * @param list + * @return + */ + private double[] toBoolArray(List list) { + double[] intArray = new double[list.size()]; + for (int i = 0; i < list.size(); i++) { + if (list.get(i) == true) { + intArray[i] = 1; + } else { + intArray[i] = 0; + } + } + return intArray; + } + /** + * Train + * + * @param X ïîëó÷åííûå âåêòîðà èç CountVectorizer + * @param y âîçìîæíûå âàðèàíòû (1 èëè 0) + * @return + * @throws InconveninentShapeException + */ + @Override + public MlModel train(List> X, List y) throws InconveninentShapeException { + + double pr = 0; + double[] sumdelta; + int i, j, k; +// try { +// weights=readFromFile(); +// } catch (IOException ex) { +// Logger.getLogger(LogisticRegression.class.getName()).log(Level.SEVERE, null, ex); +// } catch (ClassNotFoundException ex) { +// Logger.getLogger(LogisticRegression.class.getName()).log(Level.SEVERE, null, ex); +// } + weights = new double[X.get(1).size() + 1]; + X = init(X); + double delta[]; + sumdelta = new double[X.get(1).size()]; + for (int u = 0; u < ITERATES; u++) { + delta = new double[X.get(1).size()]; + for (i = 0; i < X.size(); i++) { + try { + pr = MathService.sigmoid(MathService.doProduct(toIntArray(X.get(i)), weights)); + } catch (EmptyArrayException ex) { + Logger.getLogger(LogisticRegression.class.getName()).log(Level.SEVERE, null, ex); + } + for (j = 0; j < X.get(1).size(); j++) { + delta[j] = (pr - toBoolArray(y)[i]) * X.get(i).get(j); + + } + + for (k = 0; k < X.get(1).size(); k++) { + sumdelta[k] = sumdelta[k] + delta[k]; + + } + + } + for (i = 0; i < X.get(1).size(); i++) { + sumdelta[i] = sumdelta[i] / X.size(); + + } + for (i = 0; i < X.get(1).size(); i++) { + weights[i] = weights[i] - rate * sumdelta[i]; + + } + + } + + try { + saveMlModelToFile(); + } catch (IOException ex) { + Logger.getLogger(LogisticRegression.class.getName()).log(Level.SEVERE, null, ex); + } + return this; + } + + /** + * Âñïîìîãàòåëüíûé êëàññ, êîòîðûé ïîìîãàåò âû÷èñëèòü ñóììó ïðîèçâåäåíèé + * êîîðäèíàò âåêòîðà èõ âåñîâ + * + * @param X âåêòîð + * @return + */ + private double help(List X) { + double result = 0; + for (int i = 0; i < X.size(); i++) { + result = result + X.get(i) * weights[i]; + } + return result; + } + + /** + * + * @param X + * @return + * @throws InconveninentShapeException + */ + @Override + public int[] predict(List> X) throws InconveninentShapeException { + //weights=new NewClass().nc(); + double ver; + int[] probability = new int[X.size()]; + for (int i = 0; i < X.size(); i++) { + ver = Math.exp(help(X.get(i))) / (1 + Math.exp(help(X.get(i)))); + if (ver > 0.44) { + System.out.println("Text № " + i + " is about dog " + ver); + probability[i] = 1; + } else if (ver < 0.44) { + System.out.println("Text № " + i + " is about cat " + ver); + probability[i] = 0; + } else { + System.out.println("I don't know"); + probability[i] = -1; + } + } + return probability; + } + + @Override + public double[] predictProba(double[] X) throws InconveninentShapeException { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + /** + * Ñåðèàëèçàöèÿ + * + * @param model + * @throws FileNotFoundException + * @throws IOException + */ + public void saveMlModelToFile() throws FileNotFoundException, IOException { + FileOutputStream file = new FileOutputStream("C:\\users\\user\\desktop\\work\\Saves.dat"); + ObjectOutputStream os = new ObjectOutputStream(file); + LogisticRegression lr = new LogisticRegression(); + os.writeObject(weights); + os.close(); + } + + public double[] getWeights() { + return weights; + } + + @Override + public void saveToFile(String filename) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + +} diff --git a/src/result/machinelearning/preprocessing/MlModel.java b/src/result/machinelearning/preprocessing/MlModel.java new file mode 100644 index 0000000..a29fe5e --- /dev/null +++ b/src/result/machinelearning/preprocessing/MlModel.java @@ -0,0 +1,27 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.machinelearning.preprocessing; + +import exceptions.InconveninentShapeException; +import exceptions.ModelNotFittedException; +import java.io.IOException; +import java.util.List; + +/** + * + * @author User + */ +public interface MlModel { + MlModel train(List> X, List y) throws InconveninentShapeException; + + int[] predict(List> X) throws ModelNotFittedException, InconveninentShapeException; + + double[] predictProba(double[] X) throws ModelNotFittedException, InconveninentShapeException; + + void saveToFile(String filename) throws IOException; + + +} diff --git a/src/result/machinelearning/preprocessing/PorterStemmer.java b/src/result/machinelearning/preprocessing/PorterStemmer.java new file mode 100644 index 0000000..c6322fc --- /dev/null +++ b/src/result/machinelearning/preprocessing/PorterStemmer.java @@ -0,0 +1,100 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.machinelearning.preprocessing; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Stolen by ilysko on 03.08.17. + * original: http://www.algorithmist.ru/2010/12/porter-stemmer-russian.html + */ +public class PorterStemmer { + + private static final Pattern PERFECTIVEGROUND = Pattern.compile("((ив|ивши|ившись|ыв|ывши|ывшись)|((?<=[ая])(в|вши|вшись)))$"); + + private static final Pattern REFLEXIVE = Pattern.compile("(с[яь])$"); + + private static final Pattern ADJECTIVE = Pattern.compile("(ее|ие|ые|ое|ими|ыми|ей|ий|ый|ой|ем|им|ым|ом|его|ого|ему|ому|их|ых|ую|юю|ая|яя|ою|ею)$"); + + private static final Pattern PARTICIPLE = Pattern.compile("((ивш|ывш|ующ)|((?<=[ая])(ем|нн|вш|ющ|щ)))$"); + + private static final Pattern VERB = Pattern.compile("((ила|ыла|ена|ейте|уйте|ите|или|ыли|ей|уй|ил|ыл|им|ым|ен|ило|ыло|ено|ят|ует|уют|ит|ыт|ены|ить|ыть|ишь|ую|ю)|((?<=[ая])(ла|на|ете|йте|ли|й|л|ем|н|ло|но|ет|ют|ны|ть|ешь|нно)))$"); + + private static final Pattern NOUN = Pattern.compile("(а|ев|ов|ие|ье|е|иями|ями|ами|еи|ии|и|ией|ей|ой|ий|й|иям|ям|ием|ем|ам|ом|о|у|ах|иях|ях|ы|ь|ию|ью|ю|ия|ья|я)$"); + + private static final Pattern RVRE = Pattern.compile("^(.*?[аеиоуыэюя])(.*)$"); + + private static final Pattern DERIVATIONAL = Pattern.compile(".*[^аеиоуыэюя]+[аеиоуыэюя].*ость?$"); + + private static final Pattern DER = Pattern.compile("ость?$"); + + private static final Pattern SUPERLATIVE = Pattern.compile("(ейше|ейш)$"); + + private static final Pattern I = Pattern.compile("и$"); + private static final Pattern P = Pattern.compile("ь$"); + private static final Pattern NN = Pattern.compile("нн$"); + + public String stem(String word) { + word = word.toLowerCase(); + word = word.replace('ё', 'е'); + Matcher m = RVRE.matcher(word); + if (m.matches()) { + String pre = m.group(1); + String rv = m.group(2); + String temp = PERFECTIVEGROUND.matcher(rv).replaceFirst(""); + if (temp.equals(rv)) { + rv = REFLEXIVE.matcher(rv).replaceFirst(""); + temp = ADJECTIVE.matcher(rv).replaceFirst(""); + if (!temp.equals(rv)) { + rv = temp; + rv = PARTICIPLE.matcher(rv).replaceFirst(""); + } else { + temp = VERB.matcher(rv).replaceFirst(""); + if (temp.equals(rv)) { + rv = NOUN.matcher(rv).replaceFirst(""); + } else { + rv = temp; + } + } + + } else { + rv = temp; + } + + rv = I.matcher(rv).replaceFirst(""); + + if (DERIVATIONAL.matcher(rv).matches()) { + rv = DER.matcher(rv).replaceFirst(""); + } + + temp = P.matcher(rv).replaceFirst(""); + if (temp.equals(rv)) { + rv = SUPERLATIVE.matcher(rv).replaceFirst(""); + rv = NN.matcher(rv).replaceFirst("н"); + } else { + rv = temp; + } + word = pre + rv; + + } + + return word; + } + + /** + * Some tests + */ + public static void main(String[] args) { + PorterStemmer porterStemmer = new PorterStemmer(); + String[] listOfWords = new String[] {"букварь", "здравие", + "птица", "интересный", "космос", "космический"}; + for (String word: listOfWords) { + System.out.println("Результат применения PorterStemmer к слову " + word + " : " +porterStemmer.stem(word)); + } + } + +} \ No newline at end of file diff --git a/src/result/machinelearning/preprocessing/SequenceProcessor.java b/src/result/machinelearning/preprocessing/SequenceProcessor.java new file mode 100644 index 0000000..76c289b --- /dev/null +++ b/src/result/machinelearning/preprocessing/SequenceProcessor.java @@ -0,0 +1,24 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.machinelearning.preprocessing; + +import java.util.List; +import java.util.Map; + +/** + * + * @author User + */ +public interface SequenceProcessor { + public List> fitAndTransform(List listOfTexts); + + public void fit(List listOfTexts); + + public List preprocess(String text); + + public List> transform(List listOfTexts); + +} diff --git a/src/result/machinelearning/preprocessing/TfidfVectorizer.java b/src/result/machinelearning/preprocessing/TfidfVectorizer.java new file mode 100644 index 0000000..ff66a62 --- /dev/null +++ b/src/result/machinelearning/preprocessing/TfidfVectorizer.java @@ -0,0 +1,30 @@ +package result.machinelearning.preprocessing; + +import java.util.List; +import java.util.Map; + +/** + * Created by ilysko on 03.08.17. + */ +public class TfidfVectorizer implements SequenceProcessor, Transformer { + + @Override + public List> fitAndTransform(List listOfTexts) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void fit(List listOfTexts) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public List preprocess(String text) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public List> transform(List listOfTexts) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } +} diff --git a/src/result/machinelearning/preprocessing/Transformer.java b/src/result/machinelearning/preprocessing/Transformer.java new file mode 100644 index 0000000..f5e1244 --- /dev/null +++ b/src/result/machinelearning/preprocessing/Transformer.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.machinelearning.preprocessing; + +/** + * + * @author User + */ +public interface Transformer { + +} diff --git a/src/result/machinelearning/preprocessing/WordProcessor.java b/src/result/machinelearning/preprocessing/WordProcessor.java new file mode 100644 index 0000000..c31a106 --- /dev/null +++ b/src/result/machinelearning/preprocessing/WordProcessor.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.machinelearning.preprocessing; + +/** + * + * @author User + */ +public interface WordProcessor { + +} diff --git a/src/result/other/DAO.java b/src/result/other/DAO.java new file mode 100644 index 0000000..380ef17 --- /dev/null +++ b/src/result/other/DAO.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.other; + +/** + * + * @author User + */ +public interface DAO { + +} diff --git a/src/result/other/DAOImplementation.java b/src/result/other/DAOImplementation.java new file mode 100644 index 0000000..ac2a0c2 --- /dev/null +++ b/src/result/other/DAOImplementation.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.other; + +/** + * + * @author User + */ +public class DAOImplementation { + +} diff --git a/src/result/other/ModelSelectionHibernateEntity.java b/src/result/other/ModelSelectionHibernateEntity.java new file mode 100644 index 0000000..d2ff116 --- /dev/null +++ b/src/result/other/ModelSelectionHibernateEntity.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.other; + +/** + * + * @author User + */ +public class ModelSelectionHibernateEntity { + +} diff --git a/src/result/other/ReviewHibernateEntity.java b/src/result/other/ReviewHibernateEntity.java new file mode 100644 index 0000000..79633cf --- /dev/null +++ b/src/result/other/ReviewHibernateEntity.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.other; + +/** + * + * @author User + */ +public class ReviewHibernateEntity { + +} diff --git a/src/result/other/SwingModel.java b/src/result/other/SwingModel.java new file mode 100644 index 0000000..f591e48 --- /dev/null +++ b/src/result/other/SwingModel.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.other; + +/** + * + * @author User + */ +public class SwingModel { + +} diff --git a/src/result/other/SwingTraining.java b/src/result/other/SwingTraining.java new file mode 100644 index 0000000..7ae56d3 --- /dev/null +++ b/src/result/other/SwingTraining.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.other; + +/** + * + * @author User + */ +public class SwingTraining { + +} diff --git a/src/result/other/Worker.java b/src/result/other/Worker.java new file mode 100644 index 0000000..de0fd82 --- /dev/null +++ b/src/result/other/Worker.java @@ -0,0 +1,58 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.other; + +import exceptions.InconveninentShapeException; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import result.machinelearning.preprocessing.CountVectorizer; +import result.machinelearning.preprocessing.LogisticRegression; +import result.workFiles.Reading; + +/** + * + * @author Danny + */ +public class Worker { + public static void main(String[] args) throws InconveninentShapeException { + Map map = new LinkedHashMap<>(); + LogisticRegression logisticRegression = new LogisticRegression(); + Reading reading = new Reading(); + Map res = reading.readFile(109, 60); + CountVectorizer countVectorizer = new CountVectorizer(res); + List> vectors = countVectorizer.transform(); + System.out.println("Array: "+vectors.get(0)); + logisticRegression.train(vectors, countVectorizer.getTextClasses()); + logisticRegression.predict(vectors); + String path = "C:/users/user/desktop/"; + File file =new File(path+"work.txt"); + java.io.FileReader fir = null; + StringBuffer sb = new StringBuffer(); + try (BufferedReader br = new BufferedReader(new FileReader(file))) { + String s; + while ((s = br.readLine()) != null) { + sb.append(s); + sb.append("\n"); + } + System.out.println(sb.toString()); + map.put(sb.toString(), false); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + CountVectorizer cv = new CountVectorizer(map); + List> vec = cv.transform(); + //logisticRegression.predict(vec); + } +} \ No newline at end of file diff --git a/src/result/workFiles/FileWorker.java b/src/result/workFiles/FileWorker.java new file mode 100644 index 0000000..cc0d055 --- /dev/null +++ b/src/result/workFiles/FileWorker.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.workFiles; + +/** + * + * @author User + */ +public interface FileWorker { + +} diff --git a/src/result/workFiles/FileWriter.java b/src/result/workFiles/FileWriter.java new file mode 100644 index 0000000..c0dc651 --- /dev/null +++ b/src/result/workFiles/FileWriter.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.workFiles; + +/** + * + * @author User + */ +public class FileWriter implements FileWorker{ + +} diff --git a/src/result/workFiles/Reading.java b/src/result/workFiles/Reading.java new file mode 100644 index 0000000..23e5901 --- /dev/null +++ b/src/result/workFiles/Reading.java @@ -0,0 +1,60 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package result.workFiles; + +import java.io.*; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + + +/** + * + * @author User + */ +public class Reading{ + String path = "C:/users/user/desktop/texts/"; + public Map readFile(int ZeroAmount, int OneAmount){ + + Map map = new LinkedHashMap<>(); + + for(int i=1;i