further update to bot being moved to new sys machine
This commit is contained in:
parent
84396ef56c
commit
efd3a671c4
@ -1,42 +1,42 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package DataLayer;
|
package DataLayer;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.apache.commons.dbcp2.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
import DataLayer.settings;
|
import DataLayer.settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author install1
|
* @author install1
|
||||||
*/
|
*/
|
||||||
public class DBCPDataSource {
|
public class DBCPDataSource {
|
||||||
private static BasicDataSource ds = new BasicDataSource();
|
private static BasicDataSource ds = new BasicDataSource();
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
ds.setDriver(new com.mysql.cj.jdbc.Driver());
|
ds.setDriver(new com.mysql.cj.jdbc.Driver());
|
||||||
ds.setUrl(settings.url);
|
ds.setUrl(settings.url);
|
||||||
ds.setUsername(settings.username);
|
ds.setUsername(settings.username);
|
||||||
ds.setPassword(settings.password);
|
ds.setPassword(settings.password);
|
||||||
ds.setMaxTotal(-1);
|
ds.setMaxTotal(-1);
|
||||||
ds.setMinIdle(5);
|
ds.setMinIdle(5);
|
||||||
ds.setMaxIdle(-1);
|
ds.setMaxIdle(-1);
|
||||||
ds.setMaxOpenPreparedStatements(100);
|
ds.setMaxOpenPreparedStatements(100);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
Logger.getLogger(DBCPDataSource.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(DBCPDataSource.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Connection getConnection() throws SQLException {
|
public static Connection getConnection() throws SQLException {
|
||||||
return ds.getConnection();
|
return ds.getConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
private DBCPDataSource() {
|
private DBCPDataSource() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,43 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package DataLayer;
|
package DataLayer;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.apache.commons.dbcp2.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
import DataLayer.settings;
|
import DataLayer.settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author install1
|
* @author install1
|
||||||
*/
|
*/
|
||||||
public class DBCPDataSourceHLstats {
|
public class DBCPDataSourceHLstats {
|
||||||
|
|
||||||
private static BasicDataSource ds = new BasicDataSource();
|
private static BasicDataSource ds = new BasicDataSource();
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
ds.setDriver(new com.mysql.cj.jdbc.Driver());
|
ds.setDriver(new com.mysql.cj.jdbc.Driver());
|
||||||
ds.setUrl(settings.hlURL);
|
ds.setUrl(settings.hlURL);
|
||||||
ds.setUsername(settings.hlusername);
|
ds.setUsername(settings.hlusername);
|
||||||
ds.setPassword(settings.hlpassword);
|
ds.setPassword(settings.hlpassword);
|
||||||
ds.setMaxTotal(-1);
|
ds.setMaxTotal(-1);
|
||||||
ds.setMinIdle(5);
|
ds.setMinIdle(5);
|
||||||
ds.setMaxIdle(-1);
|
ds.setMaxIdle(-1);
|
||||||
ds.setMaxOpenPreparedStatements(100);
|
ds.setMaxOpenPreparedStatements(100);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
Logger.getLogger(DBCPDataSource.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(DBCPDataSource.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Connection getConnection() throws SQLException {
|
public static Connection getConnection() throws SQLException {
|
||||||
return ds.getConnection();
|
return ds.getConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
private DBCPDataSourceHLstats() {
|
private DBCPDataSourceHLstats() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,131 +1,131 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package DataLayer;
|
package DataLayer;
|
||||||
|
|
||||||
import FunctionLayer.SimilarityMatrix;
|
import FunctionLayer.SimilarityMatrix;
|
||||||
import FunctionLayer.CustomError;
|
import FunctionLayer.CustomError;
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.collect.MapMaker;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author install1
|
* @author install1
|
||||||
*/
|
*/
|
||||||
public class DataMapper {
|
public class DataMapper {
|
||||||
|
|
||||||
public static void createTables() throws CustomError {
|
public static void createTables() throws CustomError {
|
||||||
Connection l_cCon = null;
|
Connection l_cCon = null;
|
||||||
PreparedStatement l_pStatement = null;
|
PreparedStatement l_pStatement = null;
|
||||||
ResultSet l_rsSearch = null;
|
ResultSet l_rsSearch = null;
|
||||||
try {
|
try {
|
||||||
l_cCon = DBCPDataSource.getConnection();
|
l_cCon = DBCPDataSource.getConnection();
|
||||||
String l_sSQL = "CREATE TABLE IF NOT EXISTS `ArtificialAutism`.`Sentences` (`Strings` text NOT NULL)";
|
String l_sSQL = "CREATE TABLE IF NOT EXISTS `ArtificialAutism`.`Sentences` (`Strings` text NOT NULL)";
|
||||||
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
||||||
l_pStatement.execute();
|
l_pStatement.execute();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
throw new CustomError("failed in DataMapper " + ex.getMessage());
|
throw new CustomError("failed in DataMapper " + ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConcurrentMap<Integer, String> getAllStrings() throws CustomError {
|
public static ConcurrentMap<Integer, String> getAllStrings() throws CustomError {
|
||||||
ConcurrentMap<Integer, String> allStrings = new MapMaker().concurrencyLevel(2).makeMap();
|
ConcurrentMap<Integer, String> allStrings = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
Connection l_cCon = null;
|
Connection l_cCon = null;
|
||||||
PreparedStatement l_pStatement = null;
|
PreparedStatement l_pStatement = null;
|
||||||
ResultSet l_rsSearch = null;
|
ResultSet l_rsSearch = null;
|
||||||
try {
|
try {
|
||||||
l_cCon = DBCPDataSource.getConnection();
|
l_cCon = DBCPDataSource.getConnection();
|
||||||
String l_sSQL = "SELECT * FROM `Sentences`";
|
String l_sSQL = "SELECT * FROM `Sentences`";
|
||||||
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
||||||
l_rsSearch = l_pStatement.executeQuery();
|
l_rsSearch = l_pStatement.executeQuery();
|
||||||
int ij = 0;
|
int ij = 0;
|
||||||
while (l_rsSearch.next()) {
|
while (l_rsSearch.next()) {
|
||||||
allStrings.put(ij, l_rsSearch.getString(1));
|
allStrings.put(ij, l_rsSearch.getString(1));
|
||||||
ij++;
|
ij++;
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
throw new CustomError("failed in DataMapper " + ex.getMessage());
|
throw new CustomError("failed in DataMapper " + ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||||
}
|
}
|
||||||
return allStrings;
|
return allStrings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void InsertMYSQLStrings(ConcurrentMap<Integer, String> str) throws CustomError {
|
public static void InsertMYSQLStrings(ConcurrentMap<Integer, String> str) throws CustomError {
|
||||||
Connection l_cCon = null;
|
Connection l_cCon = null;
|
||||||
PreparedStatement l_pStatement = null;
|
PreparedStatement l_pStatement = null;
|
||||||
ResultSet l_rsSearch = null;
|
ResultSet l_rsSearch = null;
|
||||||
String l_sSQL = "INSERT IGNORE `Sentences` (`Strings`) VALUES (?)";
|
String l_sSQL = "INSERT IGNORE `Sentences` (`Strings`) VALUES (?)";
|
||||||
try {
|
try {
|
||||||
l_cCon = DBCPDataSource.getConnection();
|
l_cCon = DBCPDataSource.getConnection();
|
||||||
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
||||||
for (String str1 : str.values()) {
|
for (String str1 : str.values()) {
|
||||||
//System.out.println("adding str1: " + str1 + "\n");
|
//System.out.println("adding str1: " + str1 + "\n");
|
||||||
l_pStatement.setString(1, str1);
|
l_pStatement.setString(1, str1);
|
||||||
l_pStatement.addBatch();
|
l_pStatement.addBatch();
|
||||||
}
|
}
|
||||||
l_pStatement.executeBatch();
|
l_pStatement.executeBatch();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
throw new CustomError("failed in DataMapper " + ex.getMessage());
|
throw new CustomError("failed in DataMapper " + ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConcurrentMap<Integer, String> getHLstatsMessages() {
|
public static ConcurrentMap<Integer, String> getHLstatsMessages() {
|
||||||
ConcurrentMap<Integer, String> hlStatsMessages = new MapMaker().concurrencyLevel(2).makeMap();
|
ConcurrentMap<Integer, String> hlStatsMessages = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
try (Connection l_cCon = DBCPDataSourceHLstats.getConnection()) {
|
try (Connection l_cCon = DBCPDataSourceHLstats.getConnection()) {
|
||||||
String l_sSQL = "SELECT message FROM `hlstats_Events_Chat`";
|
String l_sSQL = "SELECT message FROM `hlstats_Events_Chat`";
|
||||||
try (PreparedStatement l_pStatement = l_cCon.prepareStatement(l_sSQL)) {
|
try (PreparedStatement l_pStatement = l_cCon.prepareStatement(l_sSQL)) {
|
||||||
try (ResultSet l_rsSearch = l_pStatement.executeQuery()) {
|
try (ResultSet l_rsSearch = l_pStatement.executeQuery()) {
|
||||||
while (l_rsSearch.next()) {
|
while (l_rsSearch.next()) {
|
||||||
hlStatsMessages.put(hlStatsMessages.size() + 1, l_rsSearch.getString(1));
|
hlStatsMessages.put(hlStatsMessages.size() + 1, l_rsSearch.getString(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
return hlStatsMessages;
|
return hlStatsMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CloseConnections(PreparedStatement ps, ResultSet rs, Connection con) {
|
public static void CloseConnections(PreparedStatement ps, ResultSet rs, Connection con) {
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
try {
|
try {
|
||||||
rs.close();
|
rs.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ps != null) {
|
if (ps != null) {
|
||||||
try {
|
try {
|
||||||
ps.close();
|
ps.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (con != null) {
|
if (con != null) {
|
||||||
try {
|
try {
|
||||||
con.close();
|
con.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package FunctionLayer;
|
package FunctionLayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author install1
|
* @author install1
|
||||||
*/
|
*/
|
||||||
public class CustomError extends Exception {
|
public class CustomError extends Exception {
|
||||||
|
|
||||||
public CustomError(String msg) {
|
public CustomError(String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,104 +1,104 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package FunctionLayer;
|
package FunctionLayer;
|
||||||
|
|
||||||
import PresentationLayer.DiscordHandler;
|
import PresentationLayer.DiscordHandler;
|
||||||
import discord4j.core.event.domain.message.MessageCreateEvent;
|
import discord4j.core.event.domain.message.MessageCreateEvent;
|
||||||
import discord4j.core.object.entity.User;
|
import discord4j.core.object.entity.User;
|
||||||
import discord4j.core.object.entity.channel.TextChannel;
|
import discord4j.core.object.entity.channel.TextChannel;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author install1
|
* @author install1
|
||||||
*/
|
*/
|
||||||
public class DoStuff {
|
public class DoStuff {
|
||||||
|
|
||||||
public static boolean occupied = false;
|
public static boolean occupied = false;
|
||||||
|
|
||||||
public static boolean isOccupied() {
|
public static boolean isOccupied() {
|
||||||
return occupied;
|
return occupied;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void doStuff(MessageCreateEvent event, String usernameBot) {
|
public static void doStuff(MessageCreateEvent event, String usernameBot) {
|
||||||
String username = null;
|
String username = null;
|
||||||
try {
|
try {
|
||||||
username = event.getMessage().getAuthor().get().getUsername();
|
username = event.getMessage().getAuthor().get().getUsername();
|
||||||
} catch (java.util.NoSuchElementException e) {
|
} catch (java.util.NoSuchElementException e) {
|
||||||
username = null;
|
username = null;
|
||||||
}
|
}
|
||||||
if (username != null && !username.equals(usernameBot)) {
|
if (username != null && !username.equals(usernameBot)) {
|
||||||
occupied = true;
|
occupied = true;
|
||||||
TextChannel block = event.getMessage().getChannel().cast(TextChannel.class).block();
|
TextChannel block = event.getMessage().getChannel().cast(TextChannel.class).block();
|
||||||
String name = block.getCategory().block().getName();
|
String name = block.getCategory().block().getName();
|
||||||
name = name.toLowerCase();
|
name = name.toLowerCase();
|
||||||
String channelName = block.getName().toLowerCase();
|
String channelName = block.getName().toLowerCase();
|
||||||
boolean channelpermissionsDenied = false;
|
boolean channelpermissionsDenied = false;
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case "public area": {
|
case "public area": {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "information area": {
|
case "information area": {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
channelpermissionsDenied = true;
|
channelpermissionsDenied = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<User> blockLast = event.getMessage().getUserMentions().buffer().blockLast();
|
List<User> blockLast = event.getMessage().getUserMentions().buffer().blockLast();
|
||||||
String content = event.getMessage().getContent();
|
String content = event.getMessage().getContent();
|
||||||
if (!channelpermissionsDenied) {
|
if (!channelpermissionsDenied) {
|
||||||
if (blockLast != null)
|
if (blockLast != null)
|
||||||
{
|
{
|
||||||
for (User user : blockLast) {
|
for (User user : blockLast) {
|
||||||
content = content.replace(user.getId().asString(), "");
|
content = content.replace(user.getId().asString(), "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MessageResponseHandler.getMessage(content);
|
MessageResponseHandler.getMessage(content);
|
||||||
}
|
}
|
||||||
boolean mentionedBot = false;
|
boolean mentionedBot = false;
|
||||||
if (blockLast != null){
|
if (blockLast != null){
|
||||||
for (User user : blockLast)
|
for (User user : blockLast)
|
||||||
{
|
{
|
||||||
if (user.getUsername().equals(usernameBot))
|
if (user.getUsername().equals(usernameBot))
|
||||||
{
|
{
|
||||||
mentionedBot = true;
|
mentionedBot = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mentionedBot || channelName.contains("general-autism")) {
|
if (mentionedBot || channelName.contains("general-autism")) {
|
||||||
try {
|
try {
|
||||||
String ResponseStr;
|
String ResponseStr;
|
||||||
ResponseStr = MessageResponseHandler.selectReponseMessage(content, username);
|
ResponseStr = MessageResponseHandler.selectReponseMessage(content, username);
|
||||||
if (!ResponseStr.isEmpty()) {
|
if (!ResponseStr.isEmpty()) {
|
||||||
System.out.print("\nResponseStr3: " + ResponseStr + "\n");
|
System.out.print("\nResponseStr3: " + ResponseStr + "\n");
|
||||||
event.getMessage().getChannel().block().createMessage(ResponseStr).block();
|
event.getMessage().getChannel().block().createMessage(ResponseStr).block();
|
||||||
}
|
}
|
||||||
} catch (CustomError ex) {
|
} catch (CustomError ex) {
|
||||||
Logger.getLogger(DoStuff.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(DoStuff.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
Datahandler.instance.checkIfUpdateStrings();
|
Datahandler.instance.checkIfUpdateStrings();
|
||||||
} catch (CustomError ex) {
|
} catch (CustomError ex) {
|
||||||
Logger.getLogger(DiscordHandler.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(DiscordHandler.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
occupied = false;
|
occupied = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,43 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package FunctionLayer;
|
package FunctionLayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author install1
|
* @author install1
|
||||||
*/
|
*/
|
||||||
public class LevenshteinDistance {
|
public class LevenshteinDistance {
|
||||||
private CharSequence lhs;
|
private CharSequence lhs;
|
||||||
private CharSequence rhs;
|
private CharSequence rhs;
|
||||||
|
|
||||||
private static int minimum(int a, int b, int c) {
|
private static int minimum(int a, int b, int c) {
|
||||||
return Math.min(Math.min(a, b), c);
|
return Math.min(Math.min(a, b), c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LevenshteinDistance(CharSequence lhs, CharSequence rhs) {
|
public LevenshteinDistance(CharSequence lhs, CharSequence rhs) {
|
||||||
this.lhs = lhs;
|
this.lhs = lhs;
|
||||||
this.rhs = rhs;
|
this.rhs = rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double computeLevenshteinDistance() {
|
public double computeLevenshteinDistance() {
|
||||||
int[][] distance = new int[lhs.length() + 1][rhs.length() + 1];
|
int[][] distance = new int[lhs.length() + 1][rhs.length() + 1];
|
||||||
for (int i = 0; i <= lhs.length(); i++) {
|
for (int i = 0; i <= lhs.length(); i++) {
|
||||||
distance[i][0] = i;
|
distance[i][0] = i;
|
||||||
}
|
}
|
||||||
for (int j = 1; j <= rhs.length(); j++) {
|
for (int j = 1; j <= rhs.length(); j++) {
|
||||||
distance[0][j] = j;
|
distance[0][j] = j;
|
||||||
}
|
}
|
||||||
for (int i = 1; i <= lhs.length(); i++) {
|
for (int i = 1; i <= lhs.length(); i++) {
|
||||||
for (int j = 1; j <= rhs.length(); j++) {
|
for (int j = 1; j <= rhs.length(); j++) {
|
||||||
distance[i][j] = minimum(
|
distance[i][j] = minimum(
|
||||||
distance[i - 1][j] + 1,
|
distance[i - 1][j] + 1,
|
||||||
distance[i][j - 1] + 1,
|
distance[i][j - 1] + 1,
|
||||||
distance[i - 1][j - 1] + ((lhs.charAt(i - 1) == rhs.charAt(j - 1)) ? 0 : 1));
|
distance[i - 1][j - 1] + ((lhs.charAt(i - 1) == rhs.charAt(j - 1)) ? 0 : 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return distance[lhs.length()][rhs.length()];
|
return distance[lhs.length()][rhs.length()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,101 +1,101 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package FunctionLayer;
|
package FunctionLayer;
|
||||||
|
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.collect.MapMaker;
|
||||||
import edu.stanford.nlp.pipeline.CoreDocument;
|
import edu.stanford.nlp.pipeline.CoreDocument;
|
||||||
import edu.stanford.nlp.pipeline.CoreEntityMention;
|
import edu.stanford.nlp.pipeline.CoreEntityMention;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author install1
|
* @author install1
|
||||||
*/
|
*/
|
||||||
public class MessageResponseHandler {
|
public class MessageResponseHandler {
|
||||||
|
|
||||||
private static ConcurrentMap<Integer, String> str = new MapMaker().concurrencyLevel(2).makeMap();
|
private static ConcurrentMap<Integer, String> str = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
|
|
||||||
public static ConcurrentMap<Integer, String> getStr() {
|
public static ConcurrentMap<Integer, String> getStr() {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setStr(ConcurrentMap<Integer, String> str) {
|
public static void setStr(ConcurrentMap<Integer, String> str) {
|
||||||
MessageResponseHandler.str = str;
|
MessageResponseHandler.str = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getMessage(String message) {
|
public static void getMessage(String message) {
|
||||||
if (message != null && !message.isEmpty()) {
|
if (message != null && !message.isEmpty()) {
|
||||||
message = message.replace("@", "");
|
message = message.replace("@", "");
|
||||||
if (message.contains("<>")) {
|
if (message.contains("<>")) {
|
||||||
message = message.substring(message.indexOf(">"));
|
message = message.substring(message.indexOf(">"));
|
||||||
}
|
}
|
||||||
if (message.startsWith("[ *")) {
|
if (message.startsWith("[ *")) {
|
||||||
message = message.substring(message.indexOf("]"));
|
message = message.substring(message.indexOf("]"));
|
||||||
}
|
}
|
||||||
str.put(str.size() + 1, message);
|
str.put(str.size() + 1, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String selectReponseMessage(String toString, String personName) throws CustomError {
|
public static String selectReponseMessage(String toString, String personName) throws CustomError {
|
||||||
ConcurrentMap<Integer, String> str1 = new MapMaker().concurrencyLevel(6).makeMap();
|
ConcurrentMap<Integer, String> str1 = new MapMaker().concurrencyLevel(6).makeMap();
|
||||||
str1.put(str1.size() + 1, toString);
|
str1.put(str1.size() + 1, toString);
|
||||||
String strreturn = "";
|
String strreturn = "";
|
||||||
for (String str : str1.values()) {
|
for (String str : str1.values()) {
|
||||||
if (!str.isEmpty()) {
|
if (!str.isEmpty()) {
|
||||||
strreturn = str;
|
strreturn = str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String getResponseMsg = Datahandler.instance.getResponseMsg(strreturn);
|
String getResponseMsg = Datahandler.instance.getResponseMsg(strreturn);
|
||||||
getResponseMsg = checkPersonPresentInSentence(personName, getResponseMsg, strreturn);
|
getResponseMsg = checkPersonPresentInSentence(personName, getResponseMsg, strreturn);
|
||||||
return getResponseMsg;
|
return getResponseMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String checkPersonPresentInSentence(String personName, String responseMsg, String userLastMessage) {
|
private static String checkPersonPresentInSentence(String personName, String responseMsg, String userLastMessage) {
|
||||||
//check if userlastmsg contains person as refference
|
//check if userlastmsg contains person as refference
|
||||||
//check if first person is author or their person of mention
|
//check if first person is author or their person of mention
|
||||||
try {
|
try {
|
||||||
String strreturn = responseMsg;
|
String strreturn = responseMsg;
|
||||||
CoreDocument pipelineCoreDcoument = new CoreDocument(responseMsg);
|
CoreDocument pipelineCoreDcoument = new CoreDocument(responseMsg);
|
||||||
CoreDocument pipelineCoreDcoumentLastMsg = new CoreDocument(userLastMessage);
|
CoreDocument pipelineCoreDcoumentLastMsg = new CoreDocument(userLastMessage);
|
||||||
Datahandler.getPipeline().annotate(pipelineCoreDcoument);
|
Datahandler.getPipeline().annotate(pipelineCoreDcoument);
|
||||||
Datahandler.getPipeline().annotate(pipelineCoreDcoumentLastMsg);
|
Datahandler.getPipeline().annotate(pipelineCoreDcoumentLastMsg);
|
||||||
String regex = "(.*?\\d){10,}";
|
String regex = "(.*?\\d){10,}";
|
||||||
for (CoreEntityMention em : pipelineCoreDcoument.entityMentions()) {
|
for (CoreEntityMention em : pipelineCoreDcoument.entityMentions()) {
|
||||||
String entityType = em.entityType();
|
String entityType = em.entityType();
|
||||||
if (entityType.equals("PERSON")) {
|
if (entityType.equals("PERSON")) {
|
||||||
String str = strreturn;
|
String str = strreturn;
|
||||||
String emText = em.text();
|
String emText = em.text();
|
||||||
Pattern pattern = Pattern.compile(regex);
|
Pattern pattern = Pattern.compile(regex);
|
||||||
Matcher matcher = pattern.matcher(personName);
|
Matcher matcher = pattern.matcher(personName);
|
||||||
boolean isMatched = matcher.matches();
|
boolean isMatched = matcher.matches();
|
||||||
if (!emText.equals(personName) && !isMatched) {
|
if (!emText.equals(personName) && !isMatched) {
|
||||||
for (CoreEntityMention emLastMsg : pipelineCoreDcoumentLastMsg.entityMentions()) {
|
for (CoreEntityMention emLastMsg : pipelineCoreDcoumentLastMsg.entityMentions()) {
|
||||||
if (!emText.equals(emLastMsg.text()) && !Character.isDigit(emLastMsg.text().trim().charAt(0))) {
|
if (!emText.equals(emLastMsg.text()) && !Character.isDigit(emLastMsg.text().trim().charAt(0))) {
|
||||||
//System.out.println("emLastMsg.text(): " + emLastMsg.text());
|
//System.out.println("emLastMsg.text(): " + emLastMsg.text());
|
||||||
str = strreturn.substring(0, strreturn.indexOf(emText)) + " "
|
str = strreturn.substring(0, strreturn.indexOf(emText)) + " "
|
||||||
+ emLastMsg + " " + strreturn.substring(strreturn.indexOf(emText));
|
+ emLastMsg + " " + strreturn.substring(strreturn.indexOf(emText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
str += " " + personName;
|
str += " " + personName;
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("SCUFFED JAYZ: " + e.getLocalizedMessage() + "\n");
|
System.out.println("SCUFFED JAYZ: " + e.getLocalizedMessage() + "\n");
|
||||||
}
|
}
|
||||||
return responseMsg;
|
return responseMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getOverHead() {
|
public static int getOverHead() {
|
||||||
int getResponseMsgOverHead = Datahandler.instance.getMessageOverHead();
|
int getResponseMsgOverHead = Datahandler.instance.getMessageOverHead();
|
||||||
return getResponseMsgOverHead;
|
return getResponseMsgOverHead;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,150 +1,150 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package FunctionLayer;
|
package FunctionLayer;
|
||||||
|
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.collect.MapMaker;
|
||||||
import edu.mit.jmwe.data.IMWE;
|
import edu.mit.jmwe.data.IMWE;
|
||||||
import edu.mit.jmwe.data.IToken;
|
import edu.mit.jmwe.data.IToken;
|
||||||
import edu.mit.jmwe.data.Token;
|
import edu.mit.jmwe.data.Token;
|
||||||
import edu.mit.jmwe.detect.CompositeDetector;
|
import edu.mit.jmwe.detect.CompositeDetector;
|
||||||
import edu.mit.jmwe.detect.Consecutive;
|
import edu.mit.jmwe.detect.Consecutive;
|
||||||
import edu.mit.jmwe.detect.Exhaustive;
|
import edu.mit.jmwe.detect.Exhaustive;
|
||||||
import edu.mit.jmwe.detect.IMWEDetector;
|
import edu.mit.jmwe.detect.IMWEDetector;
|
||||||
import edu.mit.jmwe.detect.InflectionPattern;
|
import edu.mit.jmwe.detect.InflectionPattern;
|
||||||
import edu.mit.jmwe.detect.MoreFrequentAsMWE;
|
import edu.mit.jmwe.detect.MoreFrequentAsMWE;
|
||||||
import edu.mit.jmwe.detect.ProperNouns;
|
import edu.mit.jmwe.detect.ProperNouns;
|
||||||
import edu.mit.jmwe.index.IMWEIndex;
|
import edu.mit.jmwe.index.IMWEIndex;
|
||||||
import edu.mit.jmwe.index.MWEIndex;
|
import edu.mit.jmwe.index.MWEIndex;
|
||||||
import edu.stanford.nlp.ling.CoreAnnotations;
|
import edu.stanford.nlp.ling.CoreAnnotations;
|
||||||
import edu.stanford.nlp.ling.CoreLabel;
|
import edu.stanford.nlp.ling.CoreLabel;
|
||||||
import edu.stanford.nlp.ling.JMWEAnnotation;
|
import edu.stanford.nlp.ling.JMWEAnnotation;
|
||||||
import edu.stanford.nlp.pipeline.Annotation;
|
import edu.stanford.nlp.pipeline.Annotation;
|
||||||
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
|
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
|
||||||
import edu.stanford.nlp.util.CoreMap;
|
import edu.stanford.nlp.util.CoreMap;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author install1
|
* @author install1
|
||||||
*/
|
*/
|
||||||
//maybe not public?
|
//maybe not public?
|
||||||
public class PipelineJMWESingleton {
|
public class PipelineJMWESingleton {
|
||||||
|
|
||||||
//if not needed to be volatile dont make it, increases time
|
//if not needed to be volatile dont make it, increases time
|
||||||
public volatile static PipelineJMWESingleton INSTANCE;
|
public volatile static PipelineJMWESingleton INSTANCE;
|
||||||
private static StanfordCoreNLP localNLP = initializeJMWE();
|
private static StanfordCoreNLP localNLP = initializeJMWE();
|
||||||
private static String underscoreSpaceReplacement;
|
private static String underscoreSpaceReplacement;
|
||||||
|
|
||||||
private PipelineJMWESingleton() {
|
private PipelineJMWESingleton() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getINSTANCE() {
|
public static void getINSTANCE() {
|
||||||
INSTANCE = new PipelineJMWESingleton();
|
INSTANCE = new PipelineJMWESingleton();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<String, Annotation> getJMWEAnnotation(Collection<String> strvalues) {
|
public final ConcurrentMap<String, Annotation> getJMWEAnnotation(Collection<String> strvalues) {
|
||||||
boolean verbose = false;
|
boolean verbose = false;
|
||||||
IMWEIndex index;
|
IMWEIndex index;
|
||||||
String jmweIndexData = "/home/javatests/lib/mweindex_wordnet3.0_semcor1.6.data"; // ./lib/mweindex_wordnet3.0_semcor1.6.data
|
String jmweIndexData = "/home/debian/autism_bot/lib/mweindex_wordnet3.0_semcor1.6.data"; // ./lib/mweindex_wordnet3.0_semcor1.6.data
|
||||||
String jmweIndexDataLocalTest = "E:/java8/Projects/mweindex_wordnet3.0_semcor1.6.data";
|
String jmweIndexDataLocalTest = "E:/java8/Projects/mweindex_wordnet3.0_semcor1.6.data";
|
||||||
File indexFile = new File((String) jmweIndexData);
|
File indexFile = new File((String) jmweIndexData);
|
||||||
index = new MWEIndex(indexFile);
|
index = new MWEIndex(indexFile);
|
||||||
String detectorName = "Exhaustive";
|
String detectorName = "Exhaustive";
|
||||||
try {
|
try {
|
||||||
index.open();
|
index.open();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("unable to open IMWEIndex index: " + e + "\n");
|
throw new RuntimeException("unable to open IMWEIndex index: " + e + "\n");
|
||||||
}
|
}
|
||||||
IMWEDetector detector = getDetector(index, detectorName);
|
IMWEDetector detector = getDetector(index, detectorName);
|
||||||
ConcurrentMap<String, Annotation> returnAnnotations = new MapMaker().concurrencyLevel(2).makeMap();
|
ConcurrentMap<String, Annotation> returnAnnotations = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
strvalues.forEach(str -> {
|
strvalues.forEach(str -> {
|
||||||
Annotation annoStr = new Annotation(str);
|
Annotation annoStr = new Annotation(str);
|
||||||
returnAnnotations.put(str, annoStr);
|
returnAnnotations.put(str, annoStr);
|
||||||
});
|
});
|
||||||
localNLP.annotate(returnAnnotations.values());
|
localNLP.annotate(returnAnnotations.values());
|
||||||
returnAnnotations.values().parallelStream().forEach(annoStr -> {
|
returnAnnotations.values().parallelStream().forEach(annoStr -> {
|
||||||
for (CoreMap sentence : annoStr.get(CoreAnnotations.SentencesAnnotation.class)) {
|
for (CoreMap sentence : annoStr.get(CoreAnnotations.SentencesAnnotation.class)) {
|
||||||
List<IMWE<IToken>> mwes = getjMWEInSentence(sentence, index, detector, verbose);
|
List<IMWE<IToken>> mwes = getjMWEInSentence(sentence, index, detector, verbose);
|
||||||
sentence.set(JMWEAnnotation.class, mwes);
|
sentence.set(JMWEAnnotation.class, mwes);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
index.close();
|
index.close();
|
||||||
return returnAnnotations;
|
return returnAnnotations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static StanfordCoreNLP initializeJMWE() {
|
public final static StanfordCoreNLP initializeJMWE() {
|
||||||
Properties propsJMWE;
|
Properties propsJMWE;
|
||||||
propsJMWE = new Properties();
|
propsJMWE = new Properties();
|
||||||
propsJMWE.setProperty("annotators", "tokenize,ssplit,pos,lemma");
|
propsJMWE.setProperty("annotators", "tokenize,ssplit,pos,lemma");
|
||||||
propsJMWE.setProperty("tokenize.options", "untokenizable=firstDelete");
|
propsJMWE.setProperty("tokenize.options", "untokenizable=firstDelete");
|
||||||
propsJMWE.setProperty("threads", "25");
|
propsJMWE.setProperty("threads", "25");
|
||||||
propsJMWE.setProperty("pos.maxlen", "90");
|
propsJMWE.setProperty("pos.maxlen", "90");
|
||||||
propsJMWE.setProperty("tokenize.maxlen", "90");
|
propsJMWE.setProperty("tokenize.maxlen", "90");
|
||||||
propsJMWE.setProperty("ssplit.maxlen", "90");
|
propsJMWE.setProperty("ssplit.maxlen", "90");
|
||||||
propsJMWE.setProperty("lemma.maxlen", "90");
|
propsJMWE.setProperty("lemma.maxlen", "90");
|
||||||
underscoreSpaceReplacement = "-";
|
underscoreSpaceReplacement = "-";
|
||||||
localNLP = new StanfordCoreNLP(propsJMWE);
|
localNLP = new StanfordCoreNLP(propsJMWE);
|
||||||
System.out.println("finished singleton constructor \n");
|
System.out.println("finished singleton constructor \n");
|
||||||
return localNLP;
|
return localNLP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMWEDetector getDetector(IMWEIndex index, String detector) {
|
public IMWEDetector getDetector(IMWEIndex index, String detector) {
|
||||||
IMWEDetector iMWEdetector = null;
|
IMWEDetector iMWEdetector = null;
|
||||||
switch (detector) {
|
switch (detector) {
|
||||||
case "Consecutive":
|
case "Consecutive":
|
||||||
iMWEdetector = new Consecutive(index);
|
iMWEdetector = new Consecutive(index);
|
||||||
break;
|
break;
|
||||||
case "Exhaustive":
|
case "Exhaustive":
|
||||||
iMWEdetector = new Exhaustive(index);
|
iMWEdetector = new Exhaustive(index);
|
||||||
break;
|
break;
|
||||||
case "ProperNouns":
|
case "ProperNouns":
|
||||||
iMWEdetector = ProperNouns.getInstance();
|
iMWEdetector = ProperNouns.getInstance();
|
||||||
break;
|
break;
|
||||||
case "Complex":
|
case "Complex":
|
||||||
iMWEdetector = new CompositeDetector(ProperNouns.getInstance(),
|
iMWEdetector = new CompositeDetector(ProperNouns.getInstance(),
|
||||||
new MoreFrequentAsMWE(new InflectionPattern(new Consecutive(index))));
|
new MoreFrequentAsMWE(new InflectionPattern(new Consecutive(index))));
|
||||||
break;
|
break;
|
||||||
case "CompositeConsecutiveProperNouns":
|
case "CompositeConsecutiveProperNouns":
|
||||||
iMWEdetector = new CompositeDetector(new Consecutive(index), ProperNouns.getInstance());
|
iMWEdetector = new CompositeDetector(new Consecutive(index), ProperNouns.getInstance());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Invalid detector argument " + detector
|
throw new IllegalArgumentException("Invalid detector argument " + detector
|
||||||
+ ", only \"Consecutive\", \"Exhaustive\", \"ProperNouns\", \"Complex\" or \"CompositeConsecutiveProperNouns\" are supported.");
|
+ ", only \"Consecutive\", \"Exhaustive\", \"ProperNouns\", \"Complex\" or \"CompositeConsecutiveProperNouns\" are supported.");
|
||||||
}
|
}
|
||||||
return iMWEdetector;
|
return iMWEdetector;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IMWE<IToken>> getjMWEInSentence(CoreMap sentence, IMWEIndex index, IMWEDetector detector,
|
public List<IMWE<IToken>> getjMWEInSentence(CoreMap sentence, IMWEIndex index, IMWEDetector detector,
|
||||||
boolean verbose) {
|
boolean verbose) {
|
||||||
List<IToken> tokens = getITokens(sentence.get(CoreAnnotations.TokensAnnotation.class));
|
List<IToken> tokens = getITokens(sentence.get(CoreAnnotations.TokensAnnotation.class));
|
||||||
List<IMWE<IToken>> mwes = detector.detect(tokens);
|
List<IMWE<IToken>> mwes = detector.detect(tokens);
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
for (IMWE<IToken> token : mwes) {
|
for (IMWE<IToken> token : mwes) {
|
||||||
System.out.println("IMWE<IToken>: " + token);
|
System.out.println("IMWE<IToken>: " + token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mwes;
|
return mwes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IToken> getITokens(List<CoreLabel> tokens) {
|
public List<IToken> getITokens(List<CoreLabel> tokens) {
|
||||||
return getITokens(tokens, underscoreSpaceReplacement);
|
return getITokens(tokens, underscoreSpaceReplacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IToken> getITokens(List<CoreLabel> tokens, String underscoreSpaceReplacement) {
|
public List<IToken> getITokens(List<CoreLabel> tokens, String underscoreSpaceReplacement) {
|
||||||
List<IToken> sentence = new ArrayList<IToken>();
|
List<IToken> sentence = new ArrayList<IToken>();
|
||||||
for (CoreLabel token : tokens) {
|
for (CoreLabel token : tokens) {
|
||||||
sentence.add(new Token(token.originalText().replaceAll("_", underscoreSpaceReplacement).replaceAll(" ", underscoreSpaceReplacement), token.get(CoreAnnotations.PartOfSpeechAnnotation.class), token.lemma().replaceAll("_", underscoreSpaceReplacement).replaceAll(" ", underscoreSpaceReplacement)));
|
sentence.add(new Token(token.originalText().replaceAll("_", underscoreSpaceReplacement).replaceAll(" ", underscoreSpaceReplacement), token.get(CoreAnnotations.PartOfSpeechAnnotation.class), token.lemma().replaceAll("_", underscoreSpaceReplacement).replaceAll(" ", underscoreSpaceReplacement)));
|
||||||
}
|
}
|
||||||
return sentence;
|
return sentence;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,73 +1,73 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package FunctionLayer;
|
package FunctionLayer;
|
||||||
|
|
||||||
import FunctionLayer.StanfordParser.SentimentValueCache;
|
import FunctionLayer.StanfordParser.SentimentValueCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author install1
|
* @author install1
|
||||||
*/
|
*/
|
||||||
public class SimilarityMatrix {
|
public class SimilarityMatrix {
|
||||||
|
|
||||||
private String PrimaryString;
|
private String PrimaryString;
|
||||||
private String SecondaryString;
|
private String SecondaryString;
|
||||||
private double distance;
|
private double distance;
|
||||||
private SentimentValueCache cacheValue1;
|
private SentimentValueCache cacheValue1;
|
||||||
private SentimentValueCache cacheValue2;
|
private SentimentValueCache cacheValue2;
|
||||||
|
|
||||||
public final double getDistance() {
|
public final double getDistance() {
|
||||||
return distance;
|
return distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setDistance(double distance) {
|
public final void setDistance(double distance) {
|
||||||
this.distance = distance;
|
this.distance = distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimilarityMatrix(String str1, String str2) {
|
public SimilarityMatrix(String str1, String str2) {
|
||||||
this.PrimaryString = str1;
|
this.PrimaryString = str1;
|
||||||
this.SecondaryString = str2;
|
this.SecondaryString = str2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimilarityMatrix(String str1, String str2, double result) {
|
public SimilarityMatrix(String str1, String str2, double result) {
|
||||||
this.PrimaryString = str1;
|
this.PrimaryString = str1;
|
||||||
this.SecondaryString = str2;
|
this.SecondaryString = str2;
|
||||||
this.distance = result;
|
this.distance = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getPrimaryString() {
|
public final String getPrimaryString() {
|
||||||
return PrimaryString;
|
return PrimaryString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setPrimaryString(String PrimaryString) {
|
public final void setPrimaryString(String PrimaryString) {
|
||||||
this.PrimaryString = PrimaryString;
|
this.PrimaryString = PrimaryString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getSecondaryString() {
|
public final String getSecondaryString() {
|
||||||
return SecondaryString;
|
return SecondaryString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setSecondaryString(String SecondaryString) {
|
public final void setSecondaryString(String SecondaryString) {
|
||||||
this.SecondaryString = SecondaryString;
|
this.SecondaryString = SecondaryString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final SentimentValueCache getCacheValue1() {
|
public final SentimentValueCache getCacheValue1() {
|
||||||
return cacheValue1;
|
return cacheValue1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setCacheValue1(SentimentValueCache cacheValue1) {
|
public final void setCacheValue1(SentimentValueCache cacheValue1) {
|
||||||
this.cacheValue1 = cacheValue1;
|
this.cacheValue1 = cacheValue1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final SentimentValueCache getCacheValue2() {
|
public final SentimentValueCache getCacheValue2() {
|
||||||
return cacheValue2;
|
return cacheValue2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setCacheValue2(SentimentValueCache cacheValue2) {
|
public final void setCacheValue2(SentimentValueCache cacheValue2) {
|
||||||
this.cacheValue2 = cacheValue2;
|
this.cacheValue2 = cacheValue2;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,334 +1,334 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package FunctionLayer.StanfordParser;
|
package FunctionLayer.StanfordParser;
|
||||||
|
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.collect.MapMaker;
|
||||||
import edu.stanford.nlp.ling.TaggedWord;
|
import edu.stanford.nlp.ling.TaggedWord;
|
||||||
import edu.stanford.nlp.trees.GrammaticalStructure;
|
import edu.stanford.nlp.trees.GrammaticalStructure;
|
||||||
import edu.stanford.nlp.trees.Tree;
|
import edu.stanford.nlp.trees.Tree;
|
||||||
import edu.stanford.nlp.trees.TypedDependency;
|
import edu.stanford.nlp.trees.TypedDependency;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import org.ejml.simple.SimpleMatrix;
|
import org.ejml.simple.SimpleMatrix;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author install1
|
* @author install1
|
||||||
*/
|
*/
|
||||||
public class SentimentValueCache {
|
public class SentimentValueCache {
|
||||||
|
|
||||||
private String sentence;
|
private String sentence;
|
||||||
private int counter;
|
private int counter;
|
||||||
private List<List<TaggedWord>> taggedwordlist = new ArrayList();
|
private List<List<TaggedWord>> taggedwordlist = new ArrayList();
|
||||||
private final ConcurrentMap<Integer, String> tgwlistIndex = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> tgwlistIndex = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final ConcurrentMap<Integer, Tree> sentenceConstituencyParseList = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, Tree> sentenceConstituencyParseList = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final Collection<TypedDependency> allTypedDependencies = new ArrayList();
|
private final Collection<TypedDependency> allTypedDependencies = new ArrayList();
|
||||||
private final ConcurrentMap<Integer, GrammaticalStructure> gsMap = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, GrammaticalStructure> gsMap = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final ConcurrentMap<Integer, SimpleMatrix> simpleSMXlist = new MapMaker().concurrencyLevel(3).makeMap();
|
private final ConcurrentMap<Integer, SimpleMatrix> simpleSMXlist = new MapMaker().concurrencyLevel(3).makeMap();
|
||||||
private final ConcurrentMap<Integer, SimpleMatrix> simpleSMXlistVector = new MapMaker().concurrencyLevel(3).makeMap();
|
private final ConcurrentMap<Integer, SimpleMatrix> simpleSMXlistVector = new MapMaker().concurrencyLevel(3).makeMap();
|
||||||
private final ConcurrentMap<Integer, Integer> rnnPredictClassMap = new MapMaker().concurrencyLevel(3).makeMap();
|
private final ConcurrentMap<Integer, Integer> rnnPredictClassMap = new MapMaker().concurrencyLevel(3).makeMap();
|
||||||
private List classifyRaw;
|
private List classifyRaw;
|
||||||
private int mainSentiment = 0;
|
private int mainSentiment = 0;
|
||||||
private int longest = 0;
|
private int longest = 0;
|
||||||
private int tokensCounter = 0;
|
private int tokensCounter = 0;
|
||||||
private int anotatorcounter = 0;
|
private int anotatorcounter = 0;
|
||||||
private int inflectedCounterPositive = 0;
|
private int inflectedCounterPositive = 0;
|
||||||
private int inflectedCounterNegative = 0;
|
private int inflectedCounterNegative = 0;
|
||||||
private int MarkedContinuousCounter = 0;
|
private int MarkedContinuousCounter = 0;
|
||||||
private int MarkedContiniousCounterEntries = 0;
|
private int MarkedContiniousCounterEntries = 0;
|
||||||
private int UnmarkedPatternCounter = 0;
|
private int UnmarkedPatternCounter = 0;
|
||||||
private int pairCounter = 0;
|
private int pairCounter = 0;
|
||||||
private final ConcurrentMap<Integer, String> ITokenMapTag = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> ITokenMapTag = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final ConcurrentMap<Integer, String> strTokenStems = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> strTokenStems = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final ConcurrentMap<Integer, String> strTokenForm = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> strTokenForm = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final ConcurrentMap<Integer, String> strTokenGetEntry = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> strTokenGetEntry = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final ConcurrentMap<Integer, String> strTokenGetiPart = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> strTokenGetiPart = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final ConcurrentMap<Integer, String> strTokenEntryPOS = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> strTokenEntryPOS = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final ConcurrentMap<Integer, Integer> entryCounts = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, Integer> entryCounts = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final ConcurrentMap<Integer, String> nerEntities1 = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> nerEntities1 = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final ConcurrentMap<Integer, String> nerEntities2 = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> nerEntities2 = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final ConcurrentMap<Integer, String> nerEntityTokenTags = new MapMaker().concurrencyLevel(3).makeMap();
|
private final ConcurrentMap<Integer, String> nerEntityTokenTags = new MapMaker().concurrencyLevel(3).makeMap();
|
||||||
private final ConcurrentMap<Integer, String> stopwordTokens = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> stopwordTokens = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final ConcurrentMap<Integer, String> stopWordLemma = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> stopWordLemma = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
|
|
||||||
public int getPairCounter() {
|
public int getPairCounter() {
|
||||||
return pairCounter;
|
return pairCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPairCounter(int pairCounter) {
|
public void setPairCounter(int pairCounter) {
|
||||||
this.pairCounter = pairCounter;
|
this.pairCounter = pairCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStopWordLemma(String str) {
|
public void addStopWordLemma(String str) {
|
||||||
stopWordLemma.put(stopWordLemma.size(), str);
|
stopWordLemma.put(stopWordLemma.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addstopwordTokens(String str) {
|
public void addstopwordTokens(String str) {
|
||||||
stopwordTokens.put(stopwordTokens.size(), str);
|
stopwordTokens.put(stopwordTokens.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, String> getStopwordTokens() {
|
public ConcurrentMap<Integer, String> getStopwordTokens() {
|
||||||
return stopwordTokens;
|
return stopwordTokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, String> getStopWordLemma() {
|
public ConcurrentMap<Integer, String> getStopWordLemma() {
|
||||||
return stopWordLemma;
|
return stopWordLemma;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addnerEntityTokenTags(String str) {
|
public void addnerEntityTokenTags(String str) {
|
||||||
nerEntityTokenTags.put(nerEntityTokenTags.size(), str);
|
nerEntityTokenTags.put(nerEntityTokenTags.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, String> getnerEntityTokenTags() {
|
public ConcurrentMap<Integer, String> getnerEntityTokenTags() {
|
||||||
return nerEntityTokenTags;
|
return nerEntityTokenTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, String> getnerEntities1() {
|
public ConcurrentMap<Integer, String> getnerEntities1() {
|
||||||
return nerEntities1;
|
return nerEntities1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, String> getnerEntities2() {
|
public ConcurrentMap<Integer, String> getnerEntities2() {
|
||||||
return nerEntities2;
|
return nerEntities2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNEREntities1(String str) {
|
public void addNEREntities1(String str) {
|
||||||
nerEntities1.put(nerEntities1.size(), str);
|
nerEntities1.put(nerEntities1.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNEREntities2(String str) {
|
public void addNEREntities2(String str) {
|
||||||
nerEntities2.put(nerEntities2.size(), str);
|
nerEntities2.put(nerEntities2.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTaggedwords(List<List<TaggedWord>> twlist) {
|
public void setTaggedwords(List<List<TaggedWord>> twlist) {
|
||||||
taggedwordlist = twlist;
|
taggedwordlist = twlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<List<TaggedWord>> getTaggedwordlist() {
|
public List<List<TaggedWord>> getTaggedwordlist() {
|
||||||
return taggedwordlist;
|
return taggedwordlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEntryCounts(int counts) {
|
public void addEntryCounts(int counts) {
|
||||||
entryCounts.put(entryCounts.size(), counts);
|
entryCounts.put(entryCounts.size(), counts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, Integer> getEntryCounts() {
|
public ConcurrentMap<Integer, Integer> getEntryCounts() {
|
||||||
return entryCounts;
|
return entryCounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addstrTokenEntryPOS(String str) {
|
public void addstrTokenEntryPOS(String str) {
|
||||||
strTokenEntryPOS.put(strTokenEntryPOS.size(), str);
|
strTokenEntryPOS.put(strTokenEntryPOS.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, String> getstrTokenEntryPOS() {
|
public ConcurrentMap<Integer, String> getstrTokenEntryPOS() {
|
||||||
return strTokenEntryPOS;
|
return strTokenEntryPOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addstrTokenGetiPart(String str) {
|
public void addstrTokenGetiPart(String str) {
|
||||||
strTokenGetiPart.put(strTokenGetiPart.size(), str);
|
strTokenGetiPart.put(strTokenGetiPart.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, String> getstrTokenGetiPart() {
|
public ConcurrentMap<Integer, String> getstrTokenGetiPart() {
|
||||||
return strTokenGetiPart;
|
return strTokenGetiPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, String> getstrTokenGetEntry() {
|
public ConcurrentMap<Integer, String> getstrTokenGetEntry() {
|
||||||
return strTokenGetEntry;
|
return strTokenGetEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addstrTokenGetEntry(String str) {
|
public void addstrTokenGetEntry(String str) {
|
||||||
strTokenGetEntry.put(strTokenGetEntry.size(), str);
|
strTokenGetEntry.put(strTokenGetEntry.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, String> getstrTokenForm() {
|
public ConcurrentMap<Integer, String> getstrTokenForm() {
|
||||||
return strTokenForm;
|
return strTokenForm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addstrTokenForm(String str) {
|
public void addstrTokenForm(String str) {
|
||||||
strTokenForm.put(strTokenForm.size(), str);
|
strTokenForm.put(strTokenForm.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, String> getstrTokenStems() {
|
public ConcurrentMap<Integer, String> getstrTokenStems() {
|
||||||
return strTokenStems;
|
return strTokenStems;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addstrTokenStems(String str) {
|
public void addstrTokenStems(String str) {
|
||||||
strTokenStems.put(strTokenStems.size(), str);
|
strTokenStems.put(strTokenStems.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, String> getITokenMapTag() {
|
public ConcurrentMap<Integer, String> getITokenMapTag() {
|
||||||
return ITokenMapTag;
|
return ITokenMapTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addITokenMapTag(String str) {
|
public void addITokenMapTag(String str) {
|
||||||
ITokenMapTag.put(ITokenMapTag.size(), str);
|
ITokenMapTag.put(ITokenMapTag.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUnmarkedPatternCounter() {
|
public int getUnmarkedPatternCounter() {
|
||||||
return UnmarkedPatternCounter;
|
return UnmarkedPatternCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUnmarkedPatternCounter(int UnmarkedPatternCounter) {
|
public void setUnmarkedPatternCounter(int UnmarkedPatternCounter) {
|
||||||
this.UnmarkedPatternCounter = UnmarkedPatternCounter;
|
this.UnmarkedPatternCounter = UnmarkedPatternCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMarkedContiniousCounterEntries() {
|
public int getMarkedContiniousCounterEntries() {
|
||||||
return MarkedContiniousCounterEntries;
|
return MarkedContiniousCounterEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMarkedContiniousCounterEntries(int MarkedContiniousCounterEntries) {
|
public void setMarkedContiniousCounterEntries(int MarkedContiniousCounterEntries) {
|
||||||
this.MarkedContiniousCounterEntries = MarkedContiniousCounterEntries;
|
this.MarkedContiniousCounterEntries = MarkedContiniousCounterEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMarkedContinuousCounter() {
|
public int getMarkedContinuousCounter() {
|
||||||
return MarkedContinuousCounter;
|
return MarkedContinuousCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMarkedContinuousCounter(int MarkedContinuousCounter) {
|
public void setMarkedContinuousCounter(int MarkedContinuousCounter) {
|
||||||
this.MarkedContinuousCounter = MarkedContinuousCounter;
|
this.MarkedContinuousCounter = MarkedContinuousCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getInflectedCounterNegative() {
|
public int getInflectedCounterNegative() {
|
||||||
return inflectedCounterNegative;
|
return inflectedCounterNegative;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInflectedCounterNegative(int inflectedCounterNegative) {
|
public void setInflectedCounterNegative(int inflectedCounterNegative) {
|
||||||
this.inflectedCounterNegative = inflectedCounterNegative;
|
this.inflectedCounterNegative = inflectedCounterNegative;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getInflectedCounterPositive() {
|
public int getInflectedCounterPositive() {
|
||||||
return inflectedCounterPositive;
|
return inflectedCounterPositive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInflectedCounterPositive(int inflectedCounterPositive) {
|
public void setInflectedCounterPositive(int inflectedCounterPositive) {
|
||||||
this.inflectedCounterPositive = inflectedCounterPositive;
|
this.inflectedCounterPositive = inflectedCounterPositive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAnotatorcounter() {
|
public int getAnotatorcounter() {
|
||||||
return anotatorcounter;
|
return anotatorcounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAnotatorcounter(int anotatorcounter) {
|
public void setAnotatorcounter(int anotatorcounter) {
|
||||||
this.anotatorcounter = anotatorcounter;
|
this.anotatorcounter = anotatorcounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTokensCounter() {
|
public int getTokensCounter() {
|
||||||
return tokensCounter;
|
return tokensCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTokensCounter(int tokensCounter) {
|
public void setTokensCounter(int tokensCounter) {
|
||||||
this.tokensCounter = tokensCounter;
|
this.tokensCounter = tokensCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMainSentiment() {
|
public int getMainSentiment() {
|
||||||
return mainSentiment;
|
return mainSentiment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMainSentiment(int mainSentiment) {
|
public void setMainSentiment(int mainSentiment) {
|
||||||
this.mainSentiment = mainSentiment;
|
this.mainSentiment = mainSentiment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLongest() {
|
public int getLongest() {
|
||||||
return longest;
|
return longest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLongest(int longest) {
|
public void setLongest(int longest) {
|
||||||
this.longest = longest;
|
this.longest = longest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getClassifyRaw() {
|
public List getClassifyRaw() {
|
||||||
return classifyRaw;
|
return classifyRaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClassifyRaw(List classifyRaw) {
|
public void setClassifyRaw(List classifyRaw) {
|
||||||
this.classifyRaw = classifyRaw;
|
this.classifyRaw = classifyRaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, Integer> getRnnPrediectClassMap() {
|
public ConcurrentMap<Integer, Integer> getRnnPrediectClassMap() {
|
||||||
return rnnPredictClassMap;
|
return rnnPredictClassMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRNNPredictClass(int rnnPrediction) {
|
public void addRNNPredictClass(int rnnPrediction) {
|
||||||
rnnPredictClassMap.put(rnnPredictClassMap.size(), rnnPrediction);
|
rnnPredictClassMap.put(rnnPredictClassMap.size(), rnnPrediction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSimpleMatrix(SimpleMatrix SMX) {
|
public void addSimpleMatrix(SimpleMatrix SMX) {
|
||||||
simpleSMXlist.put(simpleSMXlist.size(), SMX);
|
simpleSMXlist.put(simpleSMXlist.size(), SMX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSimpleMatrixVector(SimpleMatrix SMX) {
|
public void addSimpleMatrixVector(SimpleMatrix SMX) {
|
||||||
simpleSMXlistVector.put(simpleSMXlistVector.size(), SMX);
|
simpleSMXlistVector.put(simpleSMXlistVector.size(), SMX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, GrammaticalStructure> getGsMap() {
|
public ConcurrentMap<Integer, GrammaticalStructure> getGsMap() {
|
||||||
return gsMap;
|
return gsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, SimpleMatrix> getSimpleSMXlist() {
|
public ConcurrentMap<Integer, SimpleMatrix> getSimpleSMXlist() {
|
||||||
return simpleSMXlist;
|
return simpleSMXlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, SimpleMatrix> getSimpleSMXlistVector() {
|
public ConcurrentMap<Integer, SimpleMatrix> getSimpleSMXlistVector() {
|
||||||
return simpleSMXlistVector;
|
return simpleSMXlistVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, GrammaticalStructure> getGs() {
|
public ConcurrentMap<Integer, GrammaticalStructure> getGs() {
|
||||||
return gsMap;
|
return gsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCounter() {
|
public int getCounter() {
|
||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addGS(GrammaticalStructure gs) {
|
public void addGS(GrammaticalStructure gs) {
|
||||||
gsMap.put(gsMap.size(), gs);
|
gsMap.put(gsMap.size(), gs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<TypedDependency> getAllTypedDependencies() {
|
public Collection<TypedDependency> getAllTypedDependencies() {
|
||||||
return allTypedDependencies;
|
return allTypedDependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTypedDependencies(Collection<TypedDependency> TDPlist) {
|
public void addTypedDependencies(Collection<TypedDependency> TDPlist) {
|
||||||
for (TypedDependency TDP : TDPlist) {
|
for (TypedDependency TDP : TDPlist) {
|
||||||
allTypedDependencies.add(TDP);
|
allTypedDependencies.add(TDP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, Tree> getSentenceConstituencyParseList() {
|
public ConcurrentMap<Integer, Tree> getSentenceConstituencyParseList() {
|
||||||
return sentenceConstituencyParseList;
|
return sentenceConstituencyParseList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSentenceConstituencyParse(Tree tree) {
|
public void addSentenceConstituencyParse(Tree tree) {
|
||||||
sentenceConstituencyParseList.put(sentenceConstituencyParseList.size(), tree);
|
sentenceConstituencyParseList.put(sentenceConstituencyParseList.size(), tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCounter(int counter) {
|
public void setCounter(int counter) {
|
||||||
counter = counter;
|
counter = counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSentence() {
|
public String getSentence() {
|
||||||
return sentence;
|
return sentence;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SentimentValueCache(String str, int counter) {
|
public SentimentValueCache(String str, int counter) {
|
||||||
this.sentence = str;
|
this.sentence = str;
|
||||||
this.counter = counter;
|
this.counter = counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<Integer, String> getTgwlistIndex() {
|
public ConcurrentMap<Integer, String> getTgwlistIndex() {
|
||||||
return tgwlistIndex;
|
return tgwlistIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTgwlistIndex(String str) {
|
public void addTgwlistIndex(String str) {
|
||||||
tgwlistIndex.put(tgwlistIndex.size(), str);
|
tgwlistIndex.put(tgwlistIndex.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SentimentValueCache(String str) {
|
public SentimentValueCache(String str) {
|
||||||
this.sentence = str;
|
this.sentence = str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,71 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
|
|
||||||
ps ax | grep EventNotfierDiscordBot-1.0
|
ps ax | grep EventNotfierDiscordBot-1.0
|
||||||
kill $pid (number)
|
kill $pid (number)
|
||||||
|
|
||||||
nohup screen -d -m -S nonroot java -Xmx6048M -jar /home/javatests/ArtificialAutism-1.0.jar
|
nohup screen -d -m -S nonroot java -Xmx6048M -jar /home/javatests/ArtificialAutism-1.0.jar
|
||||||
nohup screen -d -m -S nonroot java -Xmx6800M -jar /home/javatests/ArtificialAutism-1.0.jar
|
nohup screen -d -m -S nonroot java -Xmx6800M -jar /home/javatests/ArtificialAutism-1.0.jar
|
||||||
|
|
||||||
screen -ls (number1)
|
screen -ls (number1)
|
||||||
screen -X -S (number1) quit
|
screen -X -S (number1) quit
|
||||||
*/
|
*/
|
||||||
package PresentationLayer;
|
package PresentationLayer;
|
||||||
|
|
||||||
import FunctionLayer.Datahandler;
|
import FunctionLayer.Datahandler;
|
||||||
import FunctionLayer.DoStuff;
|
import FunctionLayer.DoStuff;
|
||||||
import FunctionLayer.PipelineJMWESingleton;
|
import FunctionLayer.PipelineJMWESingleton;
|
||||||
import discord4j.core.DiscordClient;
|
import discord4j.core.DiscordClient;
|
||||||
import discord4j.core.GatewayDiscordClient;
|
import discord4j.core.GatewayDiscordClient;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import DataLayer.settings;
|
import DataLayer.settings;
|
||||||
import discord4j.common.util.Snowflake;
|
import discord4j.common.util.Snowflake;
|
||||||
import discord4j.core.event.domain.message.MessageCreateEvent;
|
import discord4j.core.event.domain.message.MessageCreateEvent;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author install1
|
* @author install1
|
||||||
*/
|
*/
|
||||||
public class DiscordHandler {
|
public class DiscordHandler {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", "15");
|
System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", "15");
|
||||||
try {
|
try {
|
||||||
Datahandler.instance.initiateMYSQL();
|
Datahandler.instance.initiateMYSQL();
|
||||||
//nohup screen -d -m -S nonroot java -Xmx6900M -jar /home/javatests/ArtificialAutism-1.0.jar
|
//nohup screen -d -m -S nonroot java -Xmx6900M -jar /home/javatests/ArtificialAutism-1.0.jar
|
||||||
//uncomment db fetch when ready, just keep the comment for future reference
|
//uncomment db fetch when ready, just keep the comment for future reference
|
||||||
System.out.println("finished initiating MYSQL");
|
System.out.println("finished initiating MYSQL");
|
||||||
} catch (SQLException | IOException ex) {
|
} catch (SQLException | IOException ex) {
|
||||||
Logger.getLogger(DiscordHandler.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(DiscordHandler.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
PipelineJMWESingleton.getINSTANCE();
|
PipelineJMWESingleton.getINSTANCE();
|
||||||
Datahandler.instance.instantiateAnnotationMapJMWE();
|
Datahandler.instance.instantiateAnnotationMapJMWE();
|
||||||
Datahandler.instance.shiftReduceParserInitiate();
|
Datahandler.instance.shiftReduceParserInitiate();
|
||||||
Datahandler.instance.instantiateAnnotationMap();
|
Datahandler.instance.instantiateAnnotationMap();
|
||||||
System.out.println("FINISHED ALL ANNOTATIONS");
|
System.out.println("FINISHED ALL ANNOTATIONS");
|
||||||
Datahandler.instance.addHLstatsMessages();
|
Datahandler.instance.addHLstatsMessages();
|
||||||
Datahandler.instance.updateStringCache();
|
Datahandler.instance.updateStringCache();
|
||||||
//String token = "NTI5NzAxNTk5NjAyMjc4NDAx.Dw0vDg.7-aMjVWdQMYPl8qVNyvTCPS5F_A";
|
//String token = "NTI5NzAxNTk5NjAyMjc4NDAx.Dw0vDg.7-aMjVWdQMYPl8qVNyvTCPS5F_A";
|
||||||
String token = new settings().getDiscordToken();
|
String token = new settings().getDiscordToken();
|
||||||
final DiscordClient client = DiscordClient.create(token);
|
final DiscordClient client = DiscordClient.create(token);
|
||||||
final GatewayDiscordClient gateway = client.login().block();
|
final GatewayDiscordClient gateway = client.login().block();
|
||||||
String usernameBot = gateway.getSelf().block().getUsername();
|
String usernameBot = gateway.getSelf().block().getUsername();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
Datahandler.instance.update_autismo_socket_msg();
|
Datahandler.instance.update_autismo_socket_msg();
|
||||||
}).start();
|
}).start();
|
||||||
gateway.on(MessageCreateEvent.class).subscribe(event -> {
|
gateway.on(MessageCreateEvent.class).subscribe(event -> {
|
||||||
if (!FunctionLayer.DoStuff.isOccupied()) {
|
if (!FunctionLayer.DoStuff.isOccupied()) {
|
||||||
FunctionLayer.DoStuff.doStuff(event, usernameBot);
|
FunctionLayer.DoStuff.doStuff(event, usernameBot);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
gateway.onDisconnect().block();
|
gateway.onDisconnect().block();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user