repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
sakserv/hadoop-mini-clusters | hadoop-mini-clusters-hbase/src/main/java/com/github/sakserv/minicluster/impl/HbaseLocalCluster.java | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
| import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | miniHBaseCluster.shutdown();
miniHBaseCluster.waitUntilShutDown();
if (cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
configure(hbaseConfiguration);
// Handle Windows
WindowsLibsUtils.setHadoopHome();
}
public void configure(Configuration hbaseConfiguration) throws Exception {
hbaseConfiguration.set(HConstants.MASTER_PORT, hbaseMasterPort.toString());
hbaseConfiguration.set(HConstants.MASTER_INFO_PORT, hbaseMasterInfoPort.toString());
hbaseConfiguration.set(HConstants.HBASE_DIR, hbaseRootDir);
hbaseConfiguration.set(HConstants.ZOOKEEPER_CLIENT_PORT, zookeeperPort.toString());
hbaseConfiguration.set(HConstants.ZOOKEEPER_QUORUM, zookeeperConnectionString);
hbaseConfiguration.set(HConstants.ZOOKEEPER_ZNODE_PARENT, zookeeperZnodeParent);
hbaseConfiguration.set(HConstants.REPLICATION_ENABLE_KEY, hbaseWalReplicationEnabled.toString());
hbaseConfiguration.set("hbase.splitlog.manager.unassigned.timeout", "999999999");
hbaseConfiguration.set("hbase.splitlog.manager.timeoutmonitor.period", "999999999");
hbaseConfiguration.set("hbase.master.logcleaner.plugins", "org.apache.hadoop.hbase.master.cleaner.TimeToLiveLogCleaner");
}
@Override
public void cleanUp() throws Exception { | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
// Path: hadoop-mini-clusters-hbase/src/main/java/com/github/sakserv/minicluster/impl/HbaseLocalCluster.java
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
miniHBaseCluster.shutdown();
miniHBaseCluster.waitUntilShutDown();
if (cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
configure(hbaseConfiguration);
// Handle Windows
WindowsLibsUtils.setHadoopHome();
}
public void configure(Configuration hbaseConfiguration) throws Exception {
hbaseConfiguration.set(HConstants.MASTER_PORT, hbaseMasterPort.toString());
hbaseConfiguration.set(HConstants.MASTER_INFO_PORT, hbaseMasterInfoPort.toString());
hbaseConfiguration.set(HConstants.HBASE_DIR, hbaseRootDir);
hbaseConfiguration.set(HConstants.ZOOKEEPER_CLIENT_PORT, zookeeperPort.toString());
hbaseConfiguration.set(HConstants.ZOOKEEPER_QUORUM, zookeeperConnectionString);
hbaseConfiguration.set(HConstants.ZOOKEEPER_ZNODE_PARENT, zookeeperZnodeParent);
hbaseConfiguration.set(HConstants.REPLICATION_ENABLE_KEY, hbaseWalReplicationEnabled.toString());
hbaseConfiguration.set("hbase.splitlog.manager.unassigned.timeout", "999999999");
hbaseConfiguration.set("hbase.splitlog.manager.timeoutmonitor.period", "999999999");
hbaseConfiguration.set("hbase.master.logcleaner.plugins", "org.apache.hadoop.hbase.master.cleaner.TimeToLiveLogCleaner");
}
@Override
public void cleanUp() throws Exception { | FileUtils.deleteFolder(hbaseRootDir); |
sakserv/hadoop-mini-clusters | hadoop-mini-clusters-hivemetastore/src/main/java/com/github/sakserv/minicluster/impl/HiveLocalMetaStore.java | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
| import java.io.File;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.HiveMetaStore;
import org.apache.hadoop.hive.metastore.txn.TxnDbUtil;
import org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils; | }
@Override
public void stop() throws Exception {
stop(true);
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("HIVEMETASTORE: Stopping Hive Metastore on port: {}", hiveMetastorePort);
t.interrupt();
if (cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS,
"thrift://" + hiveMetastoreHostname + ":" + hiveMetastorePort);
hiveConf.setVar(HiveConf.ConfVars.SCRATCHDIR, hiveScratchDir);
hiveConf.setVar(HiveConf.ConfVars.METASTORECONNECTURLKEY,
"jdbc:derby:;databaseName=" + hiveMetastoreDerbyDbDir + ";create=true");
hiveConf.setVar(HiveConf.ConfVars.METASTOREWAREHOUSE, new File(hiveWarehouseDir).getAbsolutePath());
hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_IN_TEST, true);
hiveConf.set("datanucleus.schema.autoCreateTables", "true");
hiveConf.set("hive.metastore.schema.verification", "false");
// Handle Windows | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
// Path: hadoop-mini-clusters-hivemetastore/src/main/java/com/github/sakserv/minicluster/impl/HiveLocalMetaStore.java
import java.io.File;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.HiveMetaStore;
import org.apache.hadoop.hive.metastore.txn.TxnDbUtil;
import org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
}
@Override
public void stop() throws Exception {
stop(true);
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("HIVEMETASTORE: Stopping Hive Metastore on port: {}", hiveMetastorePort);
t.interrupt();
if (cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS,
"thrift://" + hiveMetastoreHostname + ":" + hiveMetastorePort);
hiveConf.setVar(HiveConf.ConfVars.SCRATCHDIR, hiveScratchDir);
hiveConf.setVar(HiveConf.ConfVars.METASTORECONNECTURLKEY,
"jdbc:derby:;databaseName=" + hiveMetastoreDerbyDbDir + ";create=true");
hiveConf.setVar(HiveConf.ConfVars.METASTOREWAREHOUSE, new File(hiveWarehouseDir).getAbsolutePath());
hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_IN_TEST, true);
hiveConf.set("datanucleus.schema.autoCreateTables", "true");
hiveConf.set("hive.metastore.schema.verification", "false");
// Handle Windows | WindowsLibsUtils.setHadoopHome(); |
sakserv/hadoop-mini-clusters | hadoop-mini-clusters-hivemetastore/src/main/java/com/github/sakserv/minicluster/impl/HiveLocalMetaStore.java | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
| import java.io.File;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.HiveMetaStore;
import org.apache.hadoop.hive.metastore.txn.TxnDbUtil;
import org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils; | }
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("HIVEMETASTORE: Stopping Hive Metastore on port: {}", hiveMetastorePort);
t.interrupt();
if (cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS,
"thrift://" + hiveMetastoreHostname + ":" + hiveMetastorePort);
hiveConf.setVar(HiveConf.ConfVars.SCRATCHDIR, hiveScratchDir);
hiveConf.setVar(HiveConf.ConfVars.METASTORECONNECTURLKEY,
"jdbc:derby:;databaseName=" + hiveMetastoreDerbyDbDir + ";create=true");
hiveConf.setVar(HiveConf.ConfVars.METASTOREWAREHOUSE, new File(hiveWarehouseDir).getAbsolutePath());
hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_IN_TEST, true);
hiveConf.set("datanucleus.schema.autoCreateTables", "true");
hiveConf.set("hive.metastore.schema.verification", "false");
// Handle Windows
WindowsLibsUtils.setHadoopHome();
}
@Override
public void cleanUp() throws Exception { | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
// Path: hadoop-mini-clusters-hivemetastore/src/main/java/com/github/sakserv/minicluster/impl/HiveLocalMetaStore.java
import java.io.File;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.HiveMetaStore;
import org.apache.hadoop.hive.metastore.txn.TxnDbUtil;
import org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("HIVEMETASTORE: Stopping Hive Metastore on port: {}", hiveMetastorePort);
t.interrupt();
if (cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS,
"thrift://" + hiveMetastoreHostname + ":" + hiveMetastorePort);
hiveConf.setVar(HiveConf.ConfVars.SCRATCHDIR, hiveScratchDir);
hiveConf.setVar(HiveConf.ConfVars.METASTORECONNECTURLKEY,
"jdbc:derby:;databaseName=" + hiveMetastoreDerbyDbDir + ";create=true");
hiveConf.setVar(HiveConf.ConfVars.METASTOREWAREHOUSE, new File(hiveWarehouseDir).getAbsolutePath());
hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_IN_TEST, true);
hiveConf.set("datanucleus.schema.autoCreateTables", "true");
hiveConf.set("hive.metastore.schema.verification", "false");
// Handle Windows
WindowsLibsUtils.setHadoopHome();
}
@Override
public void cleanUp() throws Exception { | FileUtils.deleteFolder(hiveMetastoreDerbyDbDir); |
sakserv/hadoop-mini-clusters | hadoop-mini-clusters-kafka/src/main/java/com/github/sakserv/minicluster/impl/KafkaLocalBroker.java | // Path: hadoop-mini-clusters-kafka/src/main/java/com/github/sakserv/minicluster/systemtime/LocalSystemTime.java
// public class LocalSystemTime implements Time {
//
// @Override
// public long milliseconds() {
// return System.currentTimeMillis();
// }
//
// @Override
// public long nanoseconds() {
// return System.nanoTime();
// }
//
// @Override
// public void sleep(long ms) {
// try {
// Thread.sleep(ms);
// } catch (InterruptedException e) {
// // no stress
// }
// }
//
// @Override
// public long hiResClockMs() {
// return System.currentTimeMillis();
// }
//
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
| import scala.collection.Seq;
import java.lang.reflect.Constructor;
import java.util.Properties;
import kafka.metrics.KafkaMetricsReporter;
import kafka.metrics.KafkaMetricsReporter$;
import kafka.utils.VerifiableProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.systemtime.LocalSystemTime;
import com.github.sakserv.minicluster.util.FileUtils;
import kafka.server.KafkaConfig;
import kafka.server.KafkaServer;
import scala.Option; | throw new IllegalArgumentException("ERROR: Missing required config: Kafka Temp Dir");
}
if(kafkaLocalBroker.zookeeperConnectionString == null) {
throw new IllegalArgumentException("ERROR: Missing required config: Zookeeper Connection String");
}
}
}
@Override
public void start() throws Exception {
LOG.info("KAFKA: Starting Kafka on port: {}", kafkaPort);
configure();
// The Kafka API for KafkaServer has changed multiple times.
// Using reflection to call the version specific constructor
// with the correct number of arguments.
// We only expect a single constructor, throw an Exception if there is not exactly 1
Class<KafkaServer> kafkaServerClazz = KafkaServer.class;
Constructor[] kafkaServerConstructors = kafkaServerClazz.getConstructors();
if(kafkaServerConstructors.length != 1) {
throw new Exception("kafka.server.KafkaServer has more than one constructor, expected only 1");
}
// We only expect 2, 3 and 4 argument constructors, throw an Exception if not
Constructor kafkaServerConstructor = kafkaServerConstructors[0];
// Kafka 2.9.2 0.8.2 (HDP 2.3.0 and HDP 2.3.2)
if (kafkaServerConstructor.getParameterTypes().length == 2) { | // Path: hadoop-mini-clusters-kafka/src/main/java/com/github/sakserv/minicluster/systemtime/LocalSystemTime.java
// public class LocalSystemTime implements Time {
//
// @Override
// public long milliseconds() {
// return System.currentTimeMillis();
// }
//
// @Override
// public long nanoseconds() {
// return System.nanoTime();
// }
//
// @Override
// public void sleep(long ms) {
// try {
// Thread.sleep(ms);
// } catch (InterruptedException e) {
// // no stress
// }
// }
//
// @Override
// public long hiResClockMs() {
// return System.currentTimeMillis();
// }
//
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
// Path: hadoop-mini-clusters-kafka/src/main/java/com/github/sakserv/minicluster/impl/KafkaLocalBroker.java
import scala.collection.Seq;
import java.lang.reflect.Constructor;
import java.util.Properties;
import kafka.metrics.KafkaMetricsReporter;
import kafka.metrics.KafkaMetricsReporter$;
import kafka.utils.VerifiableProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.systemtime.LocalSystemTime;
import com.github.sakserv.minicluster.util.FileUtils;
import kafka.server.KafkaConfig;
import kafka.server.KafkaServer;
import scala.Option;
throw new IllegalArgumentException("ERROR: Missing required config: Kafka Temp Dir");
}
if(kafkaLocalBroker.zookeeperConnectionString == null) {
throw new IllegalArgumentException("ERROR: Missing required config: Zookeeper Connection String");
}
}
}
@Override
public void start() throws Exception {
LOG.info("KAFKA: Starting Kafka on port: {}", kafkaPort);
configure();
// The Kafka API for KafkaServer has changed multiple times.
// Using reflection to call the version specific constructor
// with the correct number of arguments.
// We only expect a single constructor, throw an Exception if there is not exactly 1
Class<KafkaServer> kafkaServerClazz = KafkaServer.class;
Constructor[] kafkaServerConstructors = kafkaServerClazz.getConstructors();
if(kafkaServerConstructors.length != 1) {
throw new Exception("kafka.server.KafkaServer has more than one constructor, expected only 1");
}
// We only expect 2, 3 and 4 argument constructors, throw an Exception if not
Constructor kafkaServerConstructor = kafkaServerConstructors[0];
// Kafka 2.9.2 0.8.2 (HDP 2.3.0 and HDP 2.3.2)
if (kafkaServerConstructor.getParameterTypes().length == 2) { | kafkaServer = (KafkaServer) kafkaServerConstructor.newInstance(kafkaConfig, new LocalSystemTime()); |
sakserv/hadoop-mini-clusters | hadoop-mini-clusters-kafka/src/main/java/com/github/sakserv/minicluster/impl/KafkaLocalBroker.java | // Path: hadoop-mini-clusters-kafka/src/main/java/com/github/sakserv/minicluster/systemtime/LocalSystemTime.java
// public class LocalSystemTime implements Time {
//
// @Override
// public long milliseconds() {
// return System.currentTimeMillis();
// }
//
// @Override
// public long nanoseconds() {
// return System.nanoTime();
// }
//
// @Override
// public void sleep(long ms) {
// try {
// Thread.sleep(ms);
// } catch (InterruptedException e) {
// // no stress
// }
// }
//
// @Override
// public long hiResClockMs() {
// return System.currentTimeMillis();
// }
//
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
| import scala.collection.Seq;
import java.lang.reflect.Constructor;
import java.util.Properties;
import kafka.metrics.KafkaMetricsReporter;
import kafka.metrics.KafkaMetricsReporter$;
import kafka.utils.VerifiableProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.systemtime.LocalSystemTime;
import com.github.sakserv.minicluster.util.FileUtils;
import kafka.server.KafkaConfig;
import kafka.server.KafkaServer;
import scala.Option; | }
@Override
public void stop() throws Exception {
stop(true);
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("KAFKA: Stopping Kafka on port: {}", kafkaPort);
kafkaServer.shutdown();
if (cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
kafkaProperties.put("advertised.host.name", kafkaHostname);
kafkaProperties.put("port", kafkaPort+"");
kafkaProperties.put("broker.id", kafkaBrokerId+"");
kafkaProperties.put("log.dir", kafkaTempDir);
kafkaProperties.put("enable.zookeeper", "true");
kafkaProperties.put("zookeeper.connect", zookeeperConnectionString);
kafkaConfig = KafkaConfig.fromProps(kafkaProperties);
}
@Override
public void cleanUp() throws Exception { | // Path: hadoop-mini-clusters-kafka/src/main/java/com/github/sakserv/minicluster/systemtime/LocalSystemTime.java
// public class LocalSystemTime implements Time {
//
// @Override
// public long milliseconds() {
// return System.currentTimeMillis();
// }
//
// @Override
// public long nanoseconds() {
// return System.nanoTime();
// }
//
// @Override
// public void sleep(long ms) {
// try {
// Thread.sleep(ms);
// } catch (InterruptedException e) {
// // no stress
// }
// }
//
// @Override
// public long hiResClockMs() {
// return System.currentTimeMillis();
// }
//
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
// Path: hadoop-mini-clusters-kafka/src/main/java/com/github/sakserv/minicluster/impl/KafkaLocalBroker.java
import scala.collection.Seq;
import java.lang.reflect.Constructor;
import java.util.Properties;
import kafka.metrics.KafkaMetricsReporter;
import kafka.metrics.KafkaMetricsReporter$;
import kafka.utils.VerifiableProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.systemtime.LocalSystemTime;
import com.github.sakserv.minicluster.util.FileUtils;
import kafka.server.KafkaConfig;
import kafka.server.KafkaServer;
import scala.Option;
}
@Override
public void stop() throws Exception {
stop(true);
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("KAFKA: Stopping Kafka on port: {}", kafkaPort);
kafkaServer.shutdown();
if (cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
kafkaProperties.put("advertised.host.name", kafkaHostname);
kafkaProperties.put("port", kafkaPort+"");
kafkaProperties.put("broker.id", kafkaBrokerId+"");
kafkaProperties.put("log.dir", kafkaTempDir);
kafkaProperties.put("enable.zookeeper", "true");
kafkaProperties.put("zookeeper.connect", zookeeperConnectionString);
kafkaConfig = KafkaConfig.fromProps(kafkaProperties);
}
@Override
public void cleanUp() throws Exception { | FileUtils.deleteFolder(kafkaTempDir); |
sakserv/hadoop-mini-clusters | hadoop-mini-clusters-hdfs/src/main/java/com/github/sakserv/minicluster/impl/HdfsLocalCluster.java | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
| import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | .build();
}
@Override
public void stop() throws Exception {
stop(true);
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("HDFS: Stopping MiniDfsCluster");
miniDFSCluster.shutdown();
if(cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
if(null != hdfsEnableRunningUserAsProxyUser && hdfsEnableRunningUserAsProxyUser) {
hdfsConfig.set("hadoop.proxyuser." + System.getProperty("user.name") + ".hosts", "*");
hdfsConfig.set("hadoop.proxyuser." + System.getProperty("user.name") + ".groups", "*");
}
hdfsConfig.setBoolean("dfs.permissions", hdfsEnablePermissions);
System.setProperty("test.build.data", hdfsTempDir);
// Handle Windows | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
// Path: hadoop-mini-clusters-hdfs/src/main/java/com/github/sakserv/minicluster/impl/HdfsLocalCluster.java
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
.build();
}
@Override
public void stop() throws Exception {
stop(true);
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("HDFS: Stopping MiniDfsCluster");
miniDFSCluster.shutdown();
if(cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
if(null != hdfsEnableRunningUserAsProxyUser && hdfsEnableRunningUserAsProxyUser) {
hdfsConfig.set("hadoop.proxyuser." + System.getProperty("user.name") + ".hosts", "*");
hdfsConfig.set("hadoop.proxyuser." + System.getProperty("user.name") + ".groups", "*");
}
hdfsConfig.setBoolean("dfs.permissions", hdfsEnablePermissions);
System.setProperty("test.build.data", hdfsTempDir);
// Handle Windows | WindowsLibsUtils.setHadoopHome(); |
sakserv/hadoop-mini-clusters | hadoop-mini-clusters-hdfs/src/main/java/com/github/sakserv/minicluster/impl/HdfsLocalCluster.java | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
| import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | public void stop() throws Exception {
stop(true);
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("HDFS: Stopping MiniDfsCluster");
miniDFSCluster.shutdown();
if(cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
if(null != hdfsEnableRunningUserAsProxyUser && hdfsEnableRunningUserAsProxyUser) {
hdfsConfig.set("hadoop.proxyuser." + System.getProperty("user.name") + ".hosts", "*");
hdfsConfig.set("hadoop.proxyuser." + System.getProperty("user.name") + ".groups", "*");
}
hdfsConfig.setBoolean("dfs.permissions", hdfsEnablePermissions);
System.setProperty("test.build.data", hdfsTempDir);
// Handle Windows
WindowsLibsUtils.setHadoopHome();
}
@Override
public void cleanUp() throws Exception { | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
// Path: hadoop-mini-clusters-hdfs/src/main/java/com/github/sakserv/minicluster/impl/HdfsLocalCluster.java
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public void stop() throws Exception {
stop(true);
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("HDFS: Stopping MiniDfsCluster");
miniDFSCluster.shutdown();
if(cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
if(null != hdfsEnableRunningUserAsProxyUser && hdfsEnableRunningUserAsProxyUser) {
hdfsConfig.set("hadoop.proxyuser." + System.getProperty("user.name") + ".hosts", "*");
hdfsConfig.set("hadoop.proxyuser." + System.getProperty("user.name") + ".groups", "*");
}
hdfsConfig.setBoolean("dfs.permissions", hdfsEnablePermissions);
System.setProperty("test.build.data", hdfsTempDir);
// Handle Windows
WindowsLibsUtils.setHadoopHome();
}
@Override
public void cleanUp() throws Exception { | FileUtils.deleteFolder(hdfsTempDir); |
sakserv/hadoop-mini-clusters | hadoop-mini-clusters-zookeeper/src/main/java/com/github/sakserv/minicluster/impl/ZookeeperLocalCluster.java | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
| import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import org.apache.curator.test.InstanceSpec;
import org.apache.curator.test.TestingServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.HashMap;
import java.util.Map; | @Override
public void start() throws Exception {
LOG.info("ZOOKEEPER: Starting Zookeeper on port: {}", port);
InstanceSpec spec = new InstanceSpec(new File(tempDir), port, electionPort,
quorumPort, deleteDataDirectoryOnClose, serverId, tickTime, maxClientCnxns, customProperties);
testingServer = new TestingServer(spec, true);
}
@Override
public void stop() throws Exception {
stop(true);
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("ZOOKEEPER: Stopping Zookeeper on port: {}", port);
testingServer.stop();
if (cleanUp) {
cleanUp();
}
}
// Curator does not leverage a configuration object
@Override
public void configure() throws Exception {
}
@Override
public void cleanUp() throws Exception { | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
// Path: hadoop-mini-clusters-zookeeper/src/main/java/com/github/sakserv/minicluster/impl/ZookeeperLocalCluster.java
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import org.apache.curator.test.InstanceSpec;
import org.apache.curator.test.TestingServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
@Override
public void start() throws Exception {
LOG.info("ZOOKEEPER: Starting Zookeeper on port: {}", port);
InstanceSpec spec = new InstanceSpec(new File(tempDir), port, electionPort,
quorumPort, deleteDataDirectoryOnClose, serverId, tickTime, maxClientCnxns, customProperties);
testingServer = new TestingServer(spec, true);
}
@Override
public void stop() throws Exception {
stop(true);
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("ZOOKEEPER: Stopping Zookeeper on port: {}", port);
testingServer.stop();
if (cleanUp) {
cleanUp();
}
}
// Curator does not leverage a configuration object
@Override
public void configure() throws Exception {
}
@Override
public void cleanUp() throws Exception { | FileUtils.deleteFolder(tempDir); |
sakserv/hadoop-mini-clusters | hadoop-mini-clusters-kafka/src/test/java/com/github/sakserv/minicluster/kafka/producer/KafkaSimpleTestProducer.java | // Path: hadoop-mini-clusters-kafka/src/test/java/com/github/sakserv/minicluster/datatime/GenerateRandomDay.java
// public class GenerateRandomDay {
//
// public static String genRandomDay() {
//
// GregorianCalendar gc = new GregorianCalendar();
//
// int year = randBetween(2013, 2014);
//
// gc.set(gc.YEAR, year);
//
// int dayOfYear = randBetween(1, gc.getActualMaximum(gc.DAY_OF_YEAR));
//
// gc.set(gc.DAY_OF_YEAR, dayOfYear);
//
// return String.format("%04d-%02d-%02d", gc.get(gc.YEAR), gc.get(gc.MONTH), gc.get(gc.DAY_OF_MONTH));
//
// }
//
// public static int randBetween(int start, int end) {
// return start + (int)Math.round(Math.random() * (end - start));
// }
// }
| import java.util.HashMap;
import java.util.Map;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.datatime.GenerateRandomDay; | return this;
}
public KafkaSimpleTestProducer build() {
KafkaSimpleTestProducer kafkaSimpleTestProducer = new KafkaSimpleTestProducer(this);
return kafkaSimpleTestProducer;
}
}
public Map<String, Object> createConfig() {
Map<String, Object> config = new HashMap<String, Object>();
config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, getKafkaHostname() + ":" + getKafkaPort());
config.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
config.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
return config;
}
public void produceMessages() {
KafkaProducer<String, String> producer = new KafkaProducer<String, String>(createConfig());
int count = 0;
while(count < getMessageCount()) {
// Create the JSON object
JSONObject obj = new JSONObject();
try {
obj.put("id", String.valueOf(count));
obj.put("msg", "test-message" + 1); | // Path: hadoop-mini-clusters-kafka/src/test/java/com/github/sakserv/minicluster/datatime/GenerateRandomDay.java
// public class GenerateRandomDay {
//
// public static String genRandomDay() {
//
// GregorianCalendar gc = new GregorianCalendar();
//
// int year = randBetween(2013, 2014);
//
// gc.set(gc.YEAR, year);
//
// int dayOfYear = randBetween(1, gc.getActualMaximum(gc.DAY_OF_YEAR));
//
// gc.set(gc.DAY_OF_YEAR, dayOfYear);
//
// return String.format("%04d-%02d-%02d", gc.get(gc.YEAR), gc.get(gc.MONTH), gc.get(gc.DAY_OF_MONTH));
//
// }
//
// public static int randBetween(int start, int end) {
// return start + (int)Math.round(Math.random() * (end - start));
// }
// }
// Path: hadoop-mini-clusters-kafka/src/test/java/com/github/sakserv/minicluster/kafka/producer/KafkaSimpleTestProducer.java
import java.util.HashMap;
import java.util.Map;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.datatime.GenerateRandomDay;
return this;
}
public KafkaSimpleTestProducer build() {
KafkaSimpleTestProducer kafkaSimpleTestProducer = new KafkaSimpleTestProducer(this);
return kafkaSimpleTestProducer;
}
}
public Map<String, Object> createConfig() {
Map<String, Object> config = new HashMap<String, Object>();
config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, getKafkaHostname() + ":" + getKafkaPort());
config.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
config.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
return config;
}
public void produceMessages() {
KafkaProducer<String, String> producer = new KafkaProducer<String, String>(createConfig());
int count = 0;
while(count < getMessageCount()) {
// Create the JSON object
JSONObject obj = new JSONObject();
try {
obj.put("id", String.valueOf(count));
obj.put("msg", "test-message" + 1); | obj.put("dt", GenerateRandomDay.genRandomDay()); |
sakserv/hadoop-mini-clusters | hadoop-mini-clusters-yarn/src/main/java/com/github/sakserv/minicluster/impl/YarnLocalCluster.java | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
| import java.io.File;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.server.MiniYARNCluster;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils; | @Override
public void start() throws Exception {
LOG.info("YARN: Starting MiniYarnCluster");
configure();
miniYARNCluster = new MiniYARNCluster(testName, numResourceManagers, numNodeManagers,
numLocalDirs, numLogDirs, enableHa);
miniYARNCluster.serviceInit(configuration);
miniYARNCluster.init(configuration);
miniYARNCluster.start();
}
@Override
public void stop() throws Exception {
stop(true);
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("YARN: Stopping MiniYarnCluster");
miniYARNCluster.stop();
if(cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
// Handle Windows | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
// Path: hadoop-mini-clusters-yarn/src/main/java/com/github/sakserv/minicluster/impl/YarnLocalCluster.java
import java.io.File;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.server.MiniYARNCluster;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
@Override
public void start() throws Exception {
LOG.info("YARN: Starting MiniYarnCluster");
configure();
miniYARNCluster = new MiniYARNCluster(testName, numResourceManagers, numNodeManagers,
numLocalDirs, numLogDirs, enableHa);
miniYARNCluster.serviceInit(configuration);
miniYARNCluster.init(configuration);
miniYARNCluster.start();
}
@Override
public void stop() throws Exception {
stop(true);
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("YARN: Stopping MiniYarnCluster");
miniYARNCluster.stop();
if(cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
// Handle Windows | WindowsLibsUtils.setHadoopHome(); |
sakserv/hadoop-mini-clusters | hadoop-mini-clusters-yarn/src/main/java/com/github/sakserv/minicluster/impl/YarnLocalCluster.java | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
| import java.io.File;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.server.MiniYARNCluster;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils; | }
@Override
public void configure() throws Exception {
// Handle Windows
WindowsLibsUtils.setHadoopHome();
configuration.set(YarnConfiguration.RM_ADDRESS, resourceManagerAddress);
configuration.set(YarnConfiguration.RM_HOSTNAME, resourceManagerHostname);
configuration.set(YarnConfiguration.RM_SCHEDULER_ADDRESS, resourceManagerSchedulerAddress);
configuration.set(YarnConfiguration.RM_RESOURCE_TRACKER_ADDRESS, resourceManagerResourceTrackerAddress);
configuration.set(YarnConfiguration.RM_WEBAPP_ADDRESS, resourceManagerWebappAddress);
configuration.set(YarnConfiguration.YARN_MINICLUSTER_FIXED_PORTS, "true");
if (getUseInJvmContainerExecutor()) {
configuration.set(YarnConfiguration.NM_CONTAINER_EXECUTOR, inJvmContainerExecutorClass);
configuration.set("fs.hdfs.impl", org.apache.hadoop.hdfs.DistributedFileSystem.class.getName());
configuration.set("fs.file.impl", org.apache.hadoop.fs.LocalFileSystem.class.getName());
}
}
@Override
public void cleanUp() throws Exception {
// Depending on if we are running in the module or the parent
// project, the target folder will be in a different location.
// We don't want to nuke the entire target directory, unless only
// the mini cluster is using it.
// A reasonable check to keep things clean is to check for the existence
// of ./target/classes and only delete the mini cluster temporary dir if true.
// Delete the entire ./target if false
if (new File("./target/classes").exists()) { | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
// Path: hadoop-mini-clusters-yarn/src/main/java/com/github/sakserv/minicluster/impl/YarnLocalCluster.java
import java.io.File;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.server.MiniYARNCluster;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
}
@Override
public void configure() throws Exception {
// Handle Windows
WindowsLibsUtils.setHadoopHome();
configuration.set(YarnConfiguration.RM_ADDRESS, resourceManagerAddress);
configuration.set(YarnConfiguration.RM_HOSTNAME, resourceManagerHostname);
configuration.set(YarnConfiguration.RM_SCHEDULER_ADDRESS, resourceManagerSchedulerAddress);
configuration.set(YarnConfiguration.RM_RESOURCE_TRACKER_ADDRESS, resourceManagerResourceTrackerAddress);
configuration.set(YarnConfiguration.RM_WEBAPP_ADDRESS, resourceManagerWebappAddress);
configuration.set(YarnConfiguration.YARN_MINICLUSTER_FIXED_PORTS, "true");
if (getUseInJvmContainerExecutor()) {
configuration.set(YarnConfiguration.NM_CONTAINER_EXECUTOR, inJvmContainerExecutorClass);
configuration.set("fs.hdfs.impl", org.apache.hadoop.hdfs.DistributedFileSystem.class.getName());
configuration.set("fs.file.impl", org.apache.hadoop.fs.LocalFileSystem.class.getName());
}
}
@Override
public void cleanUp() throws Exception {
// Depending on if we are running in the module or the parent
// project, the target folder will be in a different location.
// We don't want to nuke the entire target directory, unless only
// the mini cluster is using it.
// A reasonable check to keep things clean is to check for the existence
// of ./target/classes and only delete the mini cluster temporary dir if true.
// Delete the entire ./target if false
if (new File("./target/classes").exists()) { | FileUtils.deleteFolder("./target/" + testName); |
sakserv/hadoop-mini-clusters | hadoop-mini-clusters-kdc/src/main/java/com/github/sakserv/minicluster/impl/KdcLocalCluster.java | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
| import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
import com.google.common.base.Throwables;
import com.google.common.io.Files;
import org.apache.commons.collections.CollectionUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.http.HttpConfig;
import org.apache.hadoop.minikdc.MiniKdc;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authentication.util.KerberosUtil;
import org.apache.hadoop.security.ssl.KeyStoreTestUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.*;
import static org.apache.hadoop.fs.CommonConfigurationKeys.IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SASL_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys.*; | }
@Override
public void stop() throws Exception {
stop(true);
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("KDC: Stopping MiniKdc");
miniKdc.stop();
if (cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
conf = new Properties();
conf.setProperty("kdc.port", Integer.toString(getPort()));
conf.setProperty("kdc.bind.address", getHost());
conf.setProperty("org.name", getOrgName());
conf.setProperty("org.domain", getOrgDomain());
conf.setProperty("instance", getInstance());
conf.setProperty("transport", getTransport());
conf.setProperty("max.ticket.lifetime", Integer.toString(getMaxTicketLifetime()));
conf.setProperty("max.renewable.lifetime", Integer.toString(getMaxRenewableLifetime()));
conf.setProperty("debug", Boolean.toString(getDebug()));
// Handle Windows | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
// Path: hadoop-mini-clusters-kdc/src/main/java/com/github/sakserv/minicluster/impl/KdcLocalCluster.java
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
import com.google.common.base.Throwables;
import com.google.common.io.Files;
import org.apache.commons.collections.CollectionUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.http.HttpConfig;
import org.apache.hadoop.minikdc.MiniKdc;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authentication.util.KerberosUtil;
import org.apache.hadoop.security.ssl.KeyStoreTestUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.*;
import static org.apache.hadoop.fs.CommonConfigurationKeys.IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SASL_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys.*;
}
@Override
public void stop() throws Exception {
stop(true);
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("KDC: Stopping MiniKdc");
miniKdc.stop();
if (cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
conf = new Properties();
conf.setProperty("kdc.port", Integer.toString(getPort()));
conf.setProperty("kdc.bind.address", getHost());
conf.setProperty("org.name", getOrgName());
conf.setProperty("org.domain", getOrgDomain());
conf.setProperty("instance", getInstance());
conf.setProperty("transport", getTransport());
conf.setProperty("max.ticket.lifetime", Integer.toString(getMaxTicketLifetime()));
conf.setProperty("max.renewable.lifetime", Integer.toString(getMaxRenewableLifetime()));
conf.setProperty("debug", Boolean.toString(getDebug()));
// Handle Windows | WindowsLibsUtils.setHadoopHome(); |
sakserv/hadoop-mini-clusters | hadoop-mini-clusters-kdc/src/main/java/com/github/sakserv/minicluster/impl/KdcLocalCluster.java | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
| import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
import com.google.common.base.Throwables;
import com.google.common.io.Files;
import org.apache.commons.collections.CollectionUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.http.HttpConfig;
import org.apache.hadoop.minikdc.MiniKdc;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authentication.util.KerberosUtil;
import org.apache.hadoop.security.ssl.KeyStoreTestUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.*;
import static org.apache.hadoop.fs.CommonConfigurationKeys.IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SASL_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys.*; | }
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("KDC: Stopping MiniKdc");
miniKdc.stop();
if (cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
conf = new Properties();
conf.setProperty("kdc.port", Integer.toString(getPort()));
conf.setProperty("kdc.bind.address", getHost());
conf.setProperty("org.name", getOrgName());
conf.setProperty("org.domain", getOrgDomain());
conf.setProperty("instance", getInstance());
conf.setProperty("transport", getTransport());
conf.setProperty("max.ticket.lifetime", Integer.toString(getMaxTicketLifetime()));
conf.setProperty("max.renewable.lifetime", Integer.toString(getMaxRenewableLifetime()));
conf.setProperty("debug", Boolean.toString(getDebug()));
// Handle Windows
WindowsLibsUtils.setHadoopHome();
}
@Override
public void cleanUp() throws Exception { | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
// Path: hadoop-mini-clusters-kdc/src/main/java/com/github/sakserv/minicluster/impl/KdcLocalCluster.java
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
import com.google.common.base.Throwables;
import com.google.common.io.Files;
import org.apache.commons.collections.CollectionUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.http.HttpConfig;
import org.apache.hadoop.minikdc.MiniKdc;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authentication.util.KerberosUtil;
import org.apache.hadoop.security.ssl.KeyStoreTestUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.*;
import static org.apache.hadoop.fs.CommonConfigurationKeys.IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SASL_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys.*;
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("KDC: Stopping MiniKdc");
miniKdc.stop();
if (cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
conf = new Properties();
conf.setProperty("kdc.port", Integer.toString(getPort()));
conf.setProperty("kdc.bind.address", getHost());
conf.setProperty("org.name", getOrgName());
conf.setProperty("org.domain", getOrgDomain());
conf.setProperty("instance", getInstance());
conf.setProperty("transport", getTransport());
conf.setProperty("max.ticket.lifetime", Integer.toString(getMaxTicketLifetime()));
conf.setProperty("max.renewable.lifetime", Integer.toString(getMaxRenewableLifetime()));
conf.setProperty("debug", Boolean.toString(getDebug()));
// Handle Windows
WindowsLibsUtils.setHadoopHome();
}
@Override
public void cleanUp() throws Exception { | FileUtils.deleteFolder(baseDir, true); |
sakserv/hadoop-mini-clusters | hadoop-mini-clusters-hiveserver2/src/main/java/com/github/sakserv/minicluster/impl/HiveLocalServer2.java | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
| import java.io.File;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hive.service.server.HiveServer2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils; | }
@Override
public void start() throws Exception {
hiveServer2 = new HiveServer2();
LOG.info("HIVESERVER2: Starting HiveServer2 on port: {}", hiveServer2Port);
configure();
hiveServer2.init(hiveConf);
hiveServer2.start();
}
@Override
public void stop() throws Exception {
stop(true);
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("HIVESERVER2: Stopping HiveServer2 on port: {}", hiveServer2Port);
hiveServer2.stop();
if (cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
// Handle Windows | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
// Path: hadoop-mini-clusters-hiveserver2/src/main/java/com/github/sakserv/minicluster/impl/HiveLocalServer2.java
import java.io.File;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hive.service.server.HiveServer2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
}
@Override
public void start() throws Exception {
hiveServer2 = new HiveServer2();
LOG.info("HIVESERVER2: Starting HiveServer2 on port: {}", hiveServer2Port);
configure();
hiveServer2.init(hiveConf);
hiveServer2.start();
}
@Override
public void stop() throws Exception {
stop(true);
}
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("HIVESERVER2: Stopping HiveServer2 on port: {}", hiveServer2Port);
hiveServer2.stop();
if (cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
// Handle Windows | WindowsLibsUtils.setHadoopHome(); |
sakserv/hadoop-mini-clusters | hadoop-mini-clusters-hiveserver2/src/main/java/com/github/sakserv/minicluster/impl/HiveLocalServer2.java | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
| import java.io.File;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hive.service.server.HiveServer2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils; | @Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("HIVESERVER2: Stopping HiveServer2 on port: {}", hiveServer2Port);
hiveServer2.stop();
if (cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
// Handle Windows
WindowsLibsUtils.setHadoopHome();
hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS,
"thrift://" + hiveMetastoreHostname + ":" + hiveMetastorePort);
hiveConf.setVar(HiveConf.ConfVars.SCRATCHDIR, hiveScratchDir);
hiveConf.setVar(HiveConf.ConfVars.METASTORECONNECTURLKEY,
"jdbc:derby:;databaseName=" + hiveMetastoreDerbyDbDir + ";create=true");
hiveConf.setVar(HiveConf.ConfVars.METASTOREWAREHOUSE, new File(hiveWarehouseDir).getAbsolutePath());
hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_IN_TEST, true);
hiveConf.setVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST, String.valueOf(hiveServer2Hostname));
hiveConf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_PORT, hiveServer2Port);
hiveConf.setVar(HiveConf.ConfVars.HIVE_ZOOKEEPER_QUORUM, zookeeperConnectionString);
hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, Boolean.TRUE);
}
@Override
public void cleanUp() throws Exception { | // Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
//
// // Logger
// private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
//
// public static void deleteFolder(String directory, boolean quietly) {
// try {
// Path directoryPath = Paths.get(directory).toAbsolutePath();
// if (!quietly) {
// LOG.info("FILEUTILS: Deleting contents of directory: {}",
// directoryPath.toAbsolutePath().toString());
// }
// Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
// throws IOException {
// Files.delete(file);
// if (!quietly) {
// LOG.info("Removing file: {}", file.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc)
// throws IOException {
// Files.delete(dir);
// if (!quietly) {
// LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
// }
// return FileVisitResult.CONTINUE;
// }
// });
// } catch (IOException e) {
// LOG.error("FILEUTILS: Unable to remove {}", directory);
// }
// }
//
// public static void deleteFolder(String directory) {
// deleteFolder(directory, false);
// }
//
// @Override
// public String toString() {
// return "FileUtils";
// }
// }
//
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java
// public class WindowsLibsUtils {
//
// // Logger
// private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class);
//
// public static void setHadoopHome() {
//
// // Set hadoop.home.dir to point to the windows lib dir
// if (System.getProperty("os.name").startsWith("Windows")) {
//
// String windowsLibDir = getHadoopHome();
//
// LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
// System.setProperty("hadoop.home.dir", windowsLibDir);
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath());
// System.load(new File(windowsLibDir + Path.SEPARATOR + "lib" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath());
//
// }
// }
//
// public static String getHadoopHome() {
//
// if(System.getProperty("HADOOP_HOME") != null) {
// LOG.info("HADOOP_HOME: " + System.getProperty("HADOOP_HOME"));
// return System.getProperty("HADOOP_HOME");
// } else if (System.getenv("HADOOP_HOME") != null) { //takes the hadoop home from system environment variable
// LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME"));
// return System.getenv("HADOOP_HOME");
// } else {
//
// File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" +
// Path.SEPARATOR + System.getProperty("hdp.release.version"));
//
// if (!windowsLibDir.exists()) {
// windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir);
// if (!windowsLibDir.exists()) {
// LOG.error("WINDOWS: ERROR: Could not find windows native libs");
// }
// }
// return windowsLibDir.getAbsolutePath();
// }
//
// }
//
// }
// Path: hadoop-mini-clusters-hiveserver2/src/main/java/com/github/sakserv/minicluster/impl/HiveLocalServer2.java
import java.io.File;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hive.service.server.HiveServer2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.util.FileUtils;
import com.github.sakserv.minicluster.util.WindowsLibsUtils;
@Override
public void stop(boolean cleanUp) throws Exception {
LOG.info("HIVESERVER2: Stopping HiveServer2 on port: {}", hiveServer2Port);
hiveServer2.stop();
if (cleanUp) {
cleanUp();
}
}
@Override
public void configure() throws Exception {
// Handle Windows
WindowsLibsUtils.setHadoopHome();
hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS,
"thrift://" + hiveMetastoreHostname + ":" + hiveMetastorePort);
hiveConf.setVar(HiveConf.ConfVars.SCRATCHDIR, hiveScratchDir);
hiveConf.setVar(HiveConf.ConfVars.METASTORECONNECTURLKEY,
"jdbc:derby:;databaseName=" + hiveMetastoreDerbyDbDir + ";create=true");
hiveConf.setVar(HiveConf.ConfVars.METASTOREWAREHOUSE, new File(hiveWarehouseDir).getAbsolutePath());
hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_IN_TEST, true);
hiveConf.setVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST, String.valueOf(hiveServer2Hostname));
hiveConf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_PORT, hiveServer2Port);
hiveConf.setVar(HiveConf.ConfVars.HIVE_ZOOKEEPER_QUORUM, zookeeperConnectionString);
hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, Boolean.TRUE);
}
@Override
public void cleanUp() throws Exception { | FileUtils.deleteFolder(hiveMetastoreDerbyDbDir); |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/weight/NameWeight.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation; | package org.edits.distance.weight;
public class NameWeight implements NamedWeightCalculator {
public static final String NAME = "name";
private static final long serialVersionUID = 1L;
private static boolean isName(String s) {
if (!Character.isUpperCase(s.charAt(0)))
return false;
for (int i = 1; i < s.length(); i++) {
char ch = s.charAt(i);
if (Character.isLowerCase(ch))
continue;
return false;
}
return true;
}
@Override
public WeightCalculator clone() {
return new NameWeight();
}
@Override
public String name() {
return NAME;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/weight/NameWeight.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
package org.edits.distance.weight;
public class NameWeight implements NamedWeightCalculator {
public static final String NAME = "name";
private static final long serialVersionUID = 1L;
private static boolean isName(String s) {
if (!Character.isUpperCase(s.charAt(0)))
return false;
for (int i = 1; i < s.length(); i++) {
char ch = s.charAt(i);
if (Character.isLowerCase(ch))
continue;
return false;
}
return true;
}
@Override
public WeightCalculator clone() {
return new NameWeight();
}
@Override
public String name() {
return NAME;
}
@Override | public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/weight/NameWeight.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation; | package org.edits.distance.weight;
public class NameWeight implements NamedWeightCalculator {
public static final String NAME = "name";
private static final long serialVersionUID = 1L;
private static boolean isName(String s) {
if (!Character.isUpperCase(s.charAt(0)))
return false;
for (int i = 1; i < s.length(); i++) {
char ch = s.charAt(i);
if (Character.isLowerCase(ch))
continue;
return false;
}
return true;
}
@Override
public WeightCalculator clone() {
return new NameWeight();
}
@Override
public String name() {
return NAME;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/weight/NameWeight.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
package org.edits.distance.weight;
public class NameWeight implements NamedWeightCalculator {
public static final String NAME = "name";
private static final long serialVersionUID = 1L;
private static boolean isName(String s) {
if (!Character.isUpperCase(s.charAt(0)))
return false;
for (int i = 1; i < s.length(); i++) {
char ch = s.charAt(i);
if (Character.isLowerCase(ch))
continue;
return false;
}
return true;
}
@Override
public WeightCalculator clone() {
return new NameWeight();
}
@Override
public String name() {
return NAME;
}
@Override | public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-nlp/src/main/java/org/edits/nlp/SpellChecker.java | // Path: edits-core/src/main/java/org/edits/MapInteger.java
// public class MapInteger extends HashMap<String, Integer> implements Comparator<String> {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// public int compare(String o1, String o2) {
// return Double.compare(get(o1), get(o2));
// }
//
// public Integer get(String s) {
// if (containsKey(s))
// return super.get(s);
// put(s, 0);
// return 0;
// }
//
// public void increment(String a) {
// put(a, get(a) + 1);
// }
//
// public void increment(String a, int value) {
// put(a, get(a) + value);
// }
//
// public List<String> ordered() {
// List<String> values = Lists.newArrayList(this.keySet());
// Collections.sort(values, this);
// return values;
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import lombok.extern.log4j.Log4j;
import opennlp.tools.util.Span;
import org.edits.MapInteger;
import com.swabunga.spell.engine.SpellDictionary;
import com.swabunga.spell.engine.SpellDictionaryHashMap;
import com.swabunga.spell.engine.Word; | package org.edits.nlp;
@Log4j
public class SpellChecker {
private static SpellChecker instance;
public static SpellChecker getInstance() {
if (instance == null) {
try {
instance = new SpellChecker(OpenNLP.getInstance());
} catch (Exception e) {
log.debug(e);
throw new RuntimeException("Could not load spell checker modules");
}
}
return instance;
}
private final SpellDictionary dict;
private final OpenNLP opennlp;
private SpellChecker(OpenNLP opennlp_) throws Exception {
opennlp = opennlp_;
InputStream im = this.getClass().getClassLoader().getResource("words.txt").openStream();
dict = new SpellDictionaryHashMap(new InputStreamReader(im));
}
public String correct(String text) throws Exception { | // Path: edits-core/src/main/java/org/edits/MapInteger.java
// public class MapInteger extends HashMap<String, Integer> implements Comparator<String> {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// public int compare(String o1, String o2) {
// return Double.compare(get(o1), get(o2));
// }
//
// public Integer get(String s) {
// if (containsKey(s))
// return super.get(s);
// put(s, 0);
// return 0;
// }
//
// public void increment(String a) {
// put(a, get(a) + 1);
// }
//
// public void increment(String a, int value) {
// put(a, get(a) + value);
// }
//
// public List<String> ordered() {
// List<String> values = Lists.newArrayList(this.keySet());
// Collections.sort(values, this);
// return values;
// }
// }
// Path: edits-nlp/src/main/java/org/edits/nlp/SpellChecker.java
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import lombok.extern.log4j.Log4j;
import opennlp.tools.util.Span;
import org.edits.MapInteger;
import com.swabunga.spell.engine.SpellDictionary;
import com.swabunga.spell.engine.SpellDictionaryHashMap;
import com.swabunga.spell.engine.Word;
package org.edits.nlp;
@Log4j
public class SpellChecker {
private static SpellChecker instance;
public static SpellChecker getInstance() {
if (instance == null) {
try {
instance = new SpellChecker(OpenNLP.getInstance());
} catch (Exception e) {
log.debug(e);
throw new RuntimeException("Could not load spell checker modules");
}
}
return instance;
}
private final SpellDictionary dict;
private final OpenNLP opennlp;
private SpellChecker(OpenNLP opennlp_) throws Exception {
opennlp = opennlp_;
InputStream im = this.getClass().getClassLoader().getResource("words.txt").openStream();
dict = new SpellDictionaryHashMap(new InputStreamReader(im));
}
public String correct(String text) throws Exception { | return correct(text, new MapInteger()); |
kouylekov/edits | edits-core/src/main/java/org/edits/rules/RulesSource.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.io.Closeable;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation; | package org.edits.rules;
public abstract class RulesSource implements Serializable, Cloneable, Closeable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public abstract void close();
| // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/rules/RulesSource.java
import java.io.Closeable;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
package org.edits.rules;
public abstract class RulesSource implements Serializable, Cloneable, Closeable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public abstract void close();
| public double contradiction(Annotation a1, Annotation a2) { |
kouylekov/edits | edits-core/src/main/java/org/edits/rules/RulesSource.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.io.Closeable;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation; | package org.edits.rules;
public abstract class RulesSource implements Serializable, Cloneable, Closeable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public abstract void close();
public double contradiction(Annotation a1, Annotation a2) {
double d = probability(a1, a2);
if (d == 0)
return 0;
if (d < 0)
return Math.abs(d);
return 0.0;
}
@Override
public abstract RulesSource clone();
public double entails(Annotation a1, Annotation a2) {
double d = probability(a1, a2);
if (d == 0)
return 0;
if (d > 0)
return d;
return 0.0;
}
| // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/rules/RulesSource.java
import java.io.Closeable;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
package org.edits.rules;
public abstract class RulesSource implements Serializable, Cloneable, Closeable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public abstract void close();
public double contradiction(Annotation a1, Annotation a2) {
double d = probability(a1, a2);
if (d == 0)
return 0;
if (d < 0)
return Math.abs(d);
return 0.0;
}
@Override
public abstract RulesSource clone();
public double entails(Annotation a1, Annotation a2) {
double d = probability(a1, a2);
if (d == 0)
return 0;
if (d > 0)
return d;
return 0.0;
}
| public abstract List<Rule> extractRules(AnnotatedText t, AnnotatedText h); |
kouylekov/edits | edits-nlp/src/main/java/org/edits/nlp/OpenNLP.java | // Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.util.ArrayList;
import java.util.List;
import lombok.extern.log4j.Log4j;
import opennlp.tools.parser.AbstractBottomUpParser;
import opennlp.tools.parser.Parse;
import opennlp.tools.parser.Parser;
import opennlp.tools.parser.ParserFactory;
import opennlp.tools.parser.ParserModel;
import opennlp.tools.postag.POSModel;
import opennlp.tools.postag.POSTagger;
import opennlp.tools.postag.POSTaggerME;
import opennlp.tools.tokenize.Tokenizer;
import opennlp.tools.tokenize.TokenizerME;
import opennlp.tools.tokenize.TokenizerModel;
import opennlp.tools.util.Sequence;
import opennlp.tools.util.Span;
import org.apache.lucene.queryparser.classic.ParseException;
import org.edits.etaf.Annotation;
import org.tartarus.snowball.ext.EnglishStemmer; | package org.edits.nlp;
@Log4j
public class OpenNLP implements org.edits.EditsTextAnnotator {
private static OpenNLP instance;
public static OpenNLP getInstance() {
if (instance == null) {
try {
instance = new OpenNLP();
} catch (Exception e) {
log.debug(e);
throw new RuntimeException("Could not load OpenNLP models");
}
}
return instance;
}
private final Parser parser;
private final EnglishStemmer stemmer;
private final POSTagger tagger;
private final Tokenizer tokenizer;
public OpenNLP() throws Exception {
tagger = new POSTaggerME(new POSModel(this.getClass().getClassLoader()
.getResourceAsStream("models/en-pos-maxent.bin")));
parser = ParserFactory.create(new ParserModel(this.getClass().getClassLoader()
.getResourceAsStream("models/en-parser-chunking.bin")));
tokenizer = new TokenizerME(new TokenizerModel(this.getClass().getClassLoader()
.getResourceAsStream("models/en-token.bin")));
stemmer = new EnglishStemmer();
log.info("OpenNLP models loaded");
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-nlp/src/main/java/org/edits/nlp/OpenNLP.java
import java.util.ArrayList;
import java.util.List;
import lombok.extern.log4j.Log4j;
import opennlp.tools.parser.AbstractBottomUpParser;
import opennlp.tools.parser.Parse;
import opennlp.tools.parser.Parser;
import opennlp.tools.parser.ParserFactory;
import opennlp.tools.parser.ParserModel;
import opennlp.tools.postag.POSModel;
import opennlp.tools.postag.POSTagger;
import opennlp.tools.postag.POSTaggerME;
import opennlp.tools.tokenize.Tokenizer;
import opennlp.tools.tokenize.TokenizerME;
import opennlp.tools.tokenize.TokenizerModel;
import opennlp.tools.util.Sequence;
import opennlp.tools.util.Span;
import org.apache.lucene.queryparser.classic.ParseException;
import org.edits.etaf.Annotation;
import org.tartarus.snowball.ext.EnglishStemmer;
package org.edits.nlp;
@Log4j
public class OpenNLP implements org.edits.EditsTextAnnotator {
private static OpenNLP instance;
public static OpenNLP getInstance() {
if (instance == null) {
try {
instance = new OpenNLP();
} catch (Exception e) {
log.debug(e);
throw new RuntimeException("Could not load OpenNLP models");
}
}
return instance;
}
private final Parser parser;
private final EnglishStemmer stemmer;
private final POSTagger tagger;
private final Tokenizer tokenizer;
public OpenNLP() throws Exception {
tagger = new POSTaggerME(new POSModel(this.getClass().getClassLoader()
.getResourceAsStream("models/en-pos-maxent.bin")));
parser = ParserFactory.create(new ParserModel(this.getClass().getClassLoader()
.getResourceAsStream("models/en-parser-chunking.bin")));
tokenizer = new TokenizerME(new TokenizerModel(this.getClass().getClassLoader()
.getResourceAsStream("models/en-token.bin")));
stemmer = new EnglishStemmer();
log.info("OpenNLP models loaded");
}
@Override | public List<Annotation> annotate(String text) throws ParseException { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/match/DefaultMatcher.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import lombok.Data; | return d[s.length()][t.length()];
}
public static double distance(String s1, String s2, boolean normalize) {
return !normalize ? distance(s1, s2) : distance(s1, s2) / ((double) s1.length() + s2.length());
}
private static boolean equals(String s1, String s2, boolean ignoreCase) {
if (s1 == null || s2 == null)
return false;
if (ignoreCase)
return s1.equalsIgnoreCase(s2);
return s1.equals(s2);
}
private boolean distanceWord = false;
private boolean ignoreCase = false;
private MatchWords strategy = MatchWords.FORM_OR_LEMMA;
@Override
public Matcher copy() {
DefaultMatcher dm = new DefaultMatcher();
dm.setDistanceWord(distanceWord);
dm.setIgnoreCase(ignoreCase);
dm.setStrategy(strategy);
return dm;
}
| // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/match/DefaultMatcher.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import lombok.Data;
return d[s.length()][t.length()];
}
public static double distance(String s1, String s2, boolean normalize) {
return !normalize ? distance(s1, s2) : distance(s1, s2) / ((double) s1.length() + s2.length());
}
private static boolean equals(String s1, String s2, boolean ignoreCase) {
if (s1 == null || s2 == null)
return false;
if (ignoreCase)
return s1.equalsIgnoreCase(s2);
return s1.equals(s2);
}
private boolean distanceWord = false;
private boolean ignoreCase = false;
private MatchWords strategy = MatchWords.FORM_OR_LEMMA;
@Override
public Matcher copy() {
DefaultMatcher dm = new DefaultMatcher();
dm.setDistanceWord(distanceWord);
dm.setIgnoreCase(ignoreCase);
dm.setStrategy(strategy);
return dm;
}
| private Double distance(Annotation w1, Annotation w2) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/match/DefaultMatcher.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import lombok.Data; | DefaultMatcher dm = new DefaultMatcher();
dm.setDistanceWord(distanceWord);
dm.setIgnoreCase(ignoreCase);
dm.setStrategy(strategy);
return dm;
}
private Double distance(Annotation w1, Annotation w2) {
String t1 = w1.getForm();
String t2 = w2.getForm();
return distance(t1, t2, true);
}
private boolean equals(Annotation w1, Annotation w2) {
if (w1 == null || w2 == null)
return false;
switch (strategy) {
case FORM:
return equals(w1.getForm(), w2.getForm(), ignoreCase);
case LEMMA:
return equals(w1.getLemma(), w2.getLemma(), ignoreCase);
case FORM_OR_LEMMA:
return equals(w1.getForm(), w2.getForm(), ignoreCase) || equals(w1.getLemma(), w2.getLemma(), ignoreCase);
case FORM_AND_LEMMA:
return equals(w1.getForm(), w2.getForm(), ignoreCase) && equals(w1.getLemma(), w2.getLemma(), ignoreCase);
}
return false;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/match/DefaultMatcher.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import lombok.Data;
DefaultMatcher dm = new DefaultMatcher();
dm.setDistanceWord(distanceWord);
dm.setIgnoreCase(ignoreCase);
dm.setStrategy(strategy);
return dm;
}
private Double distance(Annotation w1, Annotation w2) {
String t1 = w1.getForm();
String t2 = w2.getForm();
return distance(t1, t2, true);
}
private boolean equals(Annotation w1, Annotation w2) {
if (w1 == null || w2 == null)
return false;
switch (strategy) {
case FORM:
return equals(w1.getForm(), w2.getForm(), ignoreCase);
case LEMMA:
return equals(w1.getLemma(), w2.getLemma(), ignoreCase);
case FORM_OR_LEMMA:
return equals(w1.getForm(), w2.getForm(), ignoreCase) || equals(w1.getLemma(), w2.getLemma(), ignoreCase);
case FORM_AND_LEMMA:
return equals(w1.getForm(), w2.getForm(), ignoreCase) && equals(w1.getLemma(), w2.getLemma(), ignoreCase);
}
return false;
}
@Override | public double match(Annotation node1, Annotation node2, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-core/src/main/java/org/edits/engines/EvaluationStatistics.java | // Path: edits-core/src/main/java/org/edits/MapInteger.java
// public class MapInteger extends HashMap<String, Integer> implements Comparator<String> {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// public int compare(String o1, String o2) {
// return Double.compare(get(o1), get(o2));
// }
//
// public Integer get(String s) {
// if (containsKey(s))
// return super.get(s);
// put(s, 0);
// return 0;
// }
//
// public void increment(String a) {
// put(a, get(a) + 1);
// }
//
// public void increment(String a, int value) {
// put(a, get(a) + value);
// }
//
// public List<String> ordered() {
// List<String> values = Lists.newArrayList(this.keySet());
// Collections.sort(values, this);
// return values;
// }
// }
//
// Path: edits-core/src/main/java/org/edits/engines/OptimizationGoal.java
// public enum Target {
// ACCURACY, FMEASURE, PRECISION, RECALL
// }
| import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import org.edits.MapInteger;
import org.edits.engines.OptimizationGoal.Target;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps; | for (int j = 0; j < table[i].length; j++) {
if (table[i][j].length() > max)
max = table[i][j].length();
}
widths.put(i, max);
}
StringBuilder b = new StringBuilder();
for (int j = 0; j < table[0].length; j++) {
for (int i = 0; i < table.length; i++) {
String s = table[i][j];
int mw = widths.get(i);
b.append(s);
b.append(symbols(mw - s.length(), " "));
if (i != table.length - 1)
b.append(" ");
}
b.append("\n");
}
return b.toString();
}
private double accuracy;
@Getter
private List<String> classes;
@Getter
private int correct; | // Path: edits-core/src/main/java/org/edits/MapInteger.java
// public class MapInteger extends HashMap<String, Integer> implements Comparator<String> {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// public int compare(String o1, String o2) {
// return Double.compare(get(o1), get(o2));
// }
//
// public Integer get(String s) {
// if (containsKey(s))
// return super.get(s);
// put(s, 0);
// return 0;
// }
//
// public void increment(String a) {
// put(a, get(a) + 1);
// }
//
// public void increment(String a, int value) {
// put(a, get(a) + value);
// }
//
// public List<String> ordered() {
// List<String> values = Lists.newArrayList(this.keySet());
// Collections.sort(values, this);
// return values;
// }
// }
//
// Path: edits-core/src/main/java/org/edits/engines/OptimizationGoal.java
// public enum Target {
// ACCURACY, FMEASURE, PRECISION, RECALL
// }
// Path: edits-core/src/main/java/org/edits/engines/EvaluationStatistics.java
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import org.edits.MapInteger;
import org.edits.engines.OptimizationGoal.Target;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
for (int j = 0; j < table[i].length; j++) {
if (table[i][j].length() > max)
max = table[i][j].length();
}
widths.put(i, max);
}
StringBuilder b = new StringBuilder();
for (int j = 0; j < table[0].length; j++) {
for (int i = 0; i < table.length; i++) {
String s = table[i][j];
int mw = widths.get(i);
b.append(s);
b.append(symbols(mw - s.length(), " "));
if (i != table.length - 1)
b.append(" ");
}
b.append("\n");
}
return b.toString();
}
private double accuracy;
@Getter
private List<String> classes;
@Getter
private int correct; | private final MapInteger examples; |
kouylekov/edits | edits-core/src/main/java/org/edits/engines/EvaluationStatistics.java | // Path: edits-core/src/main/java/org/edits/MapInteger.java
// public class MapInteger extends HashMap<String, Integer> implements Comparator<String> {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// public int compare(String o1, String o2) {
// return Double.compare(get(o1), get(o2));
// }
//
// public Integer get(String s) {
// if (containsKey(s))
// return super.get(s);
// put(s, 0);
// return 0;
// }
//
// public void increment(String a) {
// put(a, get(a) + 1);
// }
//
// public void increment(String a, int value) {
// put(a, get(a) + value);
// }
//
// public List<String> ordered() {
// List<String> values = Lists.newArrayList(this.keySet());
// Collections.sort(values, this);
// return values;
// }
// }
//
// Path: edits-core/src/main/java/org/edits/engines/OptimizationGoal.java
// public enum Target {
// ACCURACY, FMEASURE, PRECISION, RECALL
// }
| import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import org.edits.MapInteger;
import org.edits.engines.OptimizationGoal.Target;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps; |
buff.append("=== Confusion Matrix ===" + "\n\n");
sv = new String[getClasses().size() + 1][getClasses().size() + 1];
for (int i = 0; i < getClasses().size(); i++)
sv[i][0] = getClasses().get(i);
sv[getClasses().size()][0] = "<-- classified as";
z = 1;
for (String cls : getClasses()) {
for (int i = 0; i < getClasses().size(); i++)
sv[i][z] = "" + count(cls, getClasses().get(i));
sv[getClasses().size()][z] = cls;
z++;
}
buff.append(tableToString(sv));
for (String key : getSubClasses().keySet()) {
buff.append("=== " + key + " ===\n");
buff.append(getSubClasses().get(key) + "\n");
}
return buff.toString();
}
public double value(OptimizationGoal goal) { | // Path: edits-core/src/main/java/org/edits/MapInteger.java
// public class MapInteger extends HashMap<String, Integer> implements Comparator<String> {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// public int compare(String o1, String o2) {
// return Double.compare(get(o1), get(o2));
// }
//
// public Integer get(String s) {
// if (containsKey(s))
// return super.get(s);
// put(s, 0);
// return 0;
// }
//
// public void increment(String a) {
// put(a, get(a) + 1);
// }
//
// public void increment(String a, int value) {
// put(a, get(a) + value);
// }
//
// public List<String> ordered() {
// List<String> values = Lists.newArrayList(this.keySet());
// Collections.sort(values, this);
// return values;
// }
// }
//
// Path: edits-core/src/main/java/org/edits/engines/OptimizationGoal.java
// public enum Target {
// ACCURACY, FMEASURE, PRECISION, RECALL
// }
// Path: edits-core/src/main/java/org/edits/engines/EvaluationStatistics.java
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import org.edits.MapInteger;
import org.edits.engines.OptimizationGoal.Target;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
buff.append("=== Confusion Matrix ===" + "\n\n");
sv = new String[getClasses().size() + 1][getClasses().size() + 1];
for (int i = 0; i < getClasses().size(); i++)
sv[i][0] = getClasses().get(i);
sv[getClasses().size()][0] = "<-- classified as";
z = 1;
for (String cls : getClasses()) {
for (int i = 0; i < getClasses().size(); i++)
sv[i][z] = "" + count(cls, getClasses().get(i));
sv[getClasses().size()][z] = cls;
z++;
}
buff.append(tableToString(sv));
for (String key : getSubClasses().keySet()) {
buff.append("=== " + key + " ===\n");
buff.append(getSubClasses().get(key) + "\n");
}
return buff.toString();
}
public double value(OptimizationGoal goal) { | if (Target.ACCURACY.equals(goal.getTarget())) |
kouylekov/edits | edits-nlp/src/main/java/org/edits/nlp/ClassicTreeTagger.java | // Path: edits-core/src/main/java/org/edits/EditsTextAnnotator.java
// public interface EditsTextAnnotator {
//
// public List<Annotation> annotate(String text) throws Exception;
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;
import org.edits.EditsTextAnnotator;
import org.edits.etaf.Annotation; | if (pos.startsWith("PP"))
return "pron";
if (pos.startsWith("PRO"))
return "pron";
if (pos.startsWith("WP"))
return "pron";
if (pos.startsWith("PD"))
return "pron";
if (pos.startsWith("PI"))
return "pron";
if (pos.startsWith("PR"))
return "pron";
return pos;
}
private String script;
public ClassicTreeTagger(String l) {
if (l.equals("en"))
script = "english";
if (l.equals("fr"))
script = "french";
if (l.equals("it"))
script = "italian";
if (l.equals("de"))
script = "german";
if (l.equals("es"))
script = "spanish";
}
| // Path: edits-core/src/main/java/org/edits/EditsTextAnnotator.java
// public interface EditsTextAnnotator {
//
// public List<Annotation> annotate(String text) throws Exception;
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-nlp/src/main/java/org/edits/nlp/ClassicTreeTagger.java
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;
import org.edits.EditsTextAnnotator;
import org.edits.etaf.Annotation;
if (pos.startsWith("PP"))
return "pron";
if (pos.startsWith("PRO"))
return "pron";
if (pos.startsWith("WP"))
return "pron";
if (pos.startsWith("PD"))
return "pron";
if (pos.startsWith("PI"))
return "pron";
if (pos.startsWith("PR"))
return "pron";
return pos;
}
private String script;
public ClassicTreeTagger(String l) {
if (l.equals("en"))
script = "english";
if (l.equals("fr"))
script = "french";
if (l.equals("it"))
script = "italian";
if (l.equals("de"))
script = "german";
if (l.equals("es"))
script = "spanish";
}
| public List<List<Annotation>> analyse(List<String> text) throws Exception { |
kouylekov/edits | edits-core/src/main/java/org/edits/engines/weka/features/EngineFeature.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
| import java.util.Map;
import org.edits.etaf.AnnotatedEntailmentPair;
import com.google.common.collect.Maps; | package org.edits.engines.weka.features;
public class EngineFeature extends Feature {
private static final long serialVersionUID = 1L;
private final String name;
private final Map<String, Double> results;
public EngineFeature(Map<String, Double> results_, String name_) {
results = results_;
name = name_;
}
@Override
public Feature clone() {
return new EngineFeature(Maps.newHashMap(results), name);
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
// Path: edits-core/src/main/java/org/edits/engines/weka/features/EngineFeature.java
import java.util.Map;
import org.edits.etaf.AnnotatedEntailmentPair;
import com.google.common.collect.Maps;
package org.edits.engines.weka.features;
public class EngineFeature extends Feature {
private static final long serialVersionUID = 1L;
private final String name;
private final Map<String, Double> results;
public EngineFeature(Map<String, Double> results_, String name_) {
results = results_;
name = name_;
}
@Override
public Feature clone() {
return new EngineFeature(Maps.newHashMap(results), name);
}
@Override | public double doubleValue(AnnotatedEntailmentPair pair) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/weight/ExpressionWeightCalculator.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import de.congrace.exp4j.ExpressionBuilder; | c.getCalculators().addAll(calculators);
c.setWeightH(weightH);
c.setWeightT(weightT);
return c;
}
private List<NamedWeightCalculator> calculators;
private String weightH;
private String weightT;
public ExpressionWeightCalculator() {
calculators = Lists.newArrayList();
weightH = "1";
weightT = "1";
}
@Override
public WeightCalculator clone() {
ExpressionWeightCalculator ec = new ExpressionWeightCalculator();
List<NamedWeightCalculator> newList = Lists.newArrayList();
for (NamedWeightCalculator nc : calculators)
newList.add((NamedWeightCalculator) nc.clone());
ec.setCalculators(newList);
ec.setWeightH(weightH);
ec.setWeightT(weightT);
return ec;
}
| // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/weight/ExpressionWeightCalculator.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import de.congrace.exp4j.ExpressionBuilder;
c.getCalculators().addAll(calculators);
c.setWeightH(weightH);
c.setWeightT(weightT);
return c;
}
private List<NamedWeightCalculator> calculators;
private String weightH;
private String weightT;
public ExpressionWeightCalculator() {
calculators = Lists.newArrayList();
weightH = "1";
weightT = "1";
}
@Override
public WeightCalculator clone() {
ExpressionWeightCalculator ec = new ExpressionWeightCalculator();
List<NamedWeightCalculator> newList = Lists.newArrayList();
for (NamedWeightCalculator nc : calculators)
newList.add((NamedWeightCalculator) nc.clone());
ec.setCalculators(newList);
ec.setWeightH(weightH);
ec.setWeightT(weightT);
return ec;
}
| private double weight(Annotation node, String weightString, AnnotatedText t, AnnotatedText h, boolean isT) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/weight/ExpressionWeightCalculator.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import de.congrace.exp4j.ExpressionBuilder; | c.getCalculators().addAll(calculators);
c.setWeightH(weightH);
c.setWeightT(weightT);
return c;
}
private List<NamedWeightCalculator> calculators;
private String weightH;
private String weightT;
public ExpressionWeightCalculator() {
calculators = Lists.newArrayList();
weightH = "1";
weightT = "1";
}
@Override
public WeightCalculator clone() {
ExpressionWeightCalculator ec = new ExpressionWeightCalculator();
List<NamedWeightCalculator> newList = Lists.newArrayList();
for (NamedWeightCalculator nc : calculators)
newList.add((NamedWeightCalculator) nc.clone());
ec.setCalculators(newList);
ec.setWeightH(weightH);
ec.setWeightT(weightT);
return ec;
}
| // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/weight/ExpressionWeightCalculator.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import de.congrace.exp4j.ExpressionBuilder;
c.getCalculators().addAll(calculators);
c.setWeightH(weightH);
c.setWeightT(weightT);
return c;
}
private List<NamedWeightCalculator> calculators;
private String weightH;
private String weightT;
public ExpressionWeightCalculator() {
calculators = Lists.newArrayList();
weightH = "1";
weightT = "1";
}
@Override
public WeightCalculator clone() {
ExpressionWeightCalculator ec = new ExpressionWeightCalculator();
List<NamedWeightCalculator> newList = Lists.newArrayList();
for (NamedWeightCalculator nc : calculators)
newList.add((NamedWeightCalculator) nc.clone());
ec.setCalculators(newList);
ec.setWeightH(weightH);
ec.setWeightT(weightT);
return ec;
}
| private double weight(Annotation node, String weightString, AnnotatedText t, AnnotatedText h, boolean isT) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/NgramDistance.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
*
* @author Milen Kouylekov
*
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class NgramDistance extends WeightedAlgorithm {
private static final long serialVersionUID = 1L;
private final int ngram = 3;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/NgramDistance.java
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
*
* @author Milen Kouylekov
*
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class NgramDistance extends WeightedAlgorithm {
private static final long serialVersionUID = 1L;
private final int ngram = 3;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | public double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/NgramDistance.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
*
* @author Milen Kouylekov
*
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class NgramDistance extends WeightedAlgorithm {
private static final long serialVersionUID = 1L;
private final int ngram = 3;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/NgramDistance.java
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
*
* @author Milen Kouylekov
*
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class NgramDistance extends WeightedAlgorithm {
private static final long serialVersionUID = 1L;
private final int ngram = 3;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | public double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/match/SimpleRulesMatcher.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
//
// Path: edits-core/src/main/java/org/edits/rules/RulesSource.java
// public abstract class RulesSource implements Serializable, Cloneable, Closeable {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// @Override
// public abstract void close();
//
// public double contradiction(Annotation a1, Annotation a2) {
// double d = probability(a1, a2);
// if (d == 0)
// return 0;
// if (d < 0)
// return Math.abs(d);
// return 0.0;
// }
//
// @Override
// public abstract RulesSource clone();
//
// public double entails(Annotation a1, Annotation a2) {
// double d = probability(a1, a2);
// if (d == 0)
// return 0;
// if (d > 0)
// return d;
// return 0.0;
// }
//
// public abstract List<Rule> extractRules(AnnotatedText t, AnnotatedText h);
//
// public abstract double probability(Annotation a1, Annotation a2);
//
// public abstract Set<String> uses();
//
// }
| import lombok.Data;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import org.edits.rules.RulesSource; | package org.edits.distance.match;
@Data
public class SimpleRulesMatcher implements NestedMatcher {
private static final long serialVersionUID = 1L;
private final Matcher matcher; | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
//
// Path: edits-core/src/main/java/org/edits/rules/RulesSource.java
// public abstract class RulesSource implements Serializable, Cloneable, Closeable {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// @Override
// public abstract void close();
//
// public double contradiction(Annotation a1, Annotation a2) {
// double d = probability(a1, a2);
// if (d == 0)
// return 0;
// if (d < 0)
// return Math.abs(d);
// return 0.0;
// }
//
// @Override
// public abstract RulesSource clone();
//
// public double entails(Annotation a1, Annotation a2) {
// double d = probability(a1, a2);
// if (d == 0)
// return 0;
// if (d > 0)
// return d;
// return 0.0;
// }
//
// public abstract List<Rule> extractRules(AnnotatedText t, AnnotatedText h);
//
// public abstract double probability(Annotation a1, Annotation a2);
//
// public abstract Set<String> uses();
//
// }
// Path: edits-core/src/main/java/org/edits/distance/match/SimpleRulesMatcher.java
import lombok.Data;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import org.edits.rules.RulesSource;
package org.edits.distance.match;
@Data
public class SimpleRulesMatcher implements NestedMatcher {
private static final long serialVersionUID = 1L;
private final Matcher matcher; | private final RulesSource source; |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/match/SimpleRulesMatcher.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
//
// Path: edits-core/src/main/java/org/edits/rules/RulesSource.java
// public abstract class RulesSource implements Serializable, Cloneable, Closeable {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// @Override
// public abstract void close();
//
// public double contradiction(Annotation a1, Annotation a2) {
// double d = probability(a1, a2);
// if (d == 0)
// return 0;
// if (d < 0)
// return Math.abs(d);
// return 0.0;
// }
//
// @Override
// public abstract RulesSource clone();
//
// public double entails(Annotation a1, Annotation a2) {
// double d = probability(a1, a2);
// if (d == 0)
// return 0;
// if (d > 0)
// return d;
// return 0.0;
// }
//
// public abstract List<Rule> extractRules(AnnotatedText t, AnnotatedText h);
//
// public abstract double probability(Annotation a1, Annotation a2);
//
// public abstract Set<String> uses();
//
// }
| import lombok.Data;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import org.edits.rules.RulesSource; | package org.edits.distance.match;
@Data
public class SimpleRulesMatcher implements NestedMatcher {
private static final long serialVersionUID = 1L;
private final Matcher matcher;
private final RulesSource source;
public SimpleRulesMatcher(Matcher matcher_, RulesSource source_) {
source = source_;
matcher = matcher_;
}
public SimpleRulesMatcher(RulesSource source_) {
source = source_;
matcher = new DefaultMatcher();
}
@Override
public Matcher copy() {
return new SimpleRulesMatcher(matcher.copy(), source.clone());
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
//
// Path: edits-core/src/main/java/org/edits/rules/RulesSource.java
// public abstract class RulesSource implements Serializable, Cloneable, Closeable {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// @Override
// public abstract void close();
//
// public double contradiction(Annotation a1, Annotation a2) {
// double d = probability(a1, a2);
// if (d == 0)
// return 0;
// if (d < 0)
// return Math.abs(d);
// return 0.0;
// }
//
// @Override
// public abstract RulesSource clone();
//
// public double entails(Annotation a1, Annotation a2) {
// double d = probability(a1, a2);
// if (d == 0)
// return 0;
// if (d > 0)
// return d;
// return 0.0;
// }
//
// public abstract List<Rule> extractRules(AnnotatedText t, AnnotatedText h);
//
// public abstract double probability(Annotation a1, Annotation a2);
//
// public abstract Set<String> uses();
//
// }
// Path: edits-core/src/main/java/org/edits/distance/match/SimpleRulesMatcher.java
import lombok.Data;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import org.edits.rules.RulesSource;
package org.edits.distance.match;
@Data
public class SimpleRulesMatcher implements NestedMatcher {
private static final long serialVersionUID = 1L;
private final Matcher matcher;
private final RulesSource source;
public SimpleRulesMatcher(Matcher matcher_, RulesSource source_) {
source = source_;
matcher = matcher_;
}
public SimpleRulesMatcher(RulesSource source_) {
source = source_;
matcher = new DefaultMatcher();
}
@Override
public Matcher copy() {
return new SimpleRulesMatcher(matcher.copy(), source.clone());
}
@Override | public double match(Annotation node1, Annotation node2, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/match/SimpleRulesMatcher.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
//
// Path: edits-core/src/main/java/org/edits/rules/RulesSource.java
// public abstract class RulesSource implements Serializable, Cloneable, Closeable {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// @Override
// public abstract void close();
//
// public double contradiction(Annotation a1, Annotation a2) {
// double d = probability(a1, a2);
// if (d == 0)
// return 0;
// if (d < 0)
// return Math.abs(d);
// return 0.0;
// }
//
// @Override
// public abstract RulesSource clone();
//
// public double entails(Annotation a1, Annotation a2) {
// double d = probability(a1, a2);
// if (d == 0)
// return 0;
// if (d > 0)
// return d;
// return 0.0;
// }
//
// public abstract List<Rule> extractRules(AnnotatedText t, AnnotatedText h);
//
// public abstract double probability(Annotation a1, Annotation a2);
//
// public abstract Set<String> uses();
//
// }
| import lombok.Data;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import org.edits.rules.RulesSource; | package org.edits.distance.match;
@Data
public class SimpleRulesMatcher implements NestedMatcher {
private static final long serialVersionUID = 1L;
private final Matcher matcher;
private final RulesSource source;
public SimpleRulesMatcher(Matcher matcher_, RulesSource source_) {
source = source_;
matcher = matcher_;
}
public SimpleRulesMatcher(RulesSource source_) {
source = source_;
matcher = new DefaultMatcher();
}
@Override
public Matcher copy() {
return new SimpleRulesMatcher(matcher.copy(), source.clone());
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
//
// Path: edits-core/src/main/java/org/edits/rules/RulesSource.java
// public abstract class RulesSource implements Serializable, Cloneable, Closeable {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// @Override
// public abstract void close();
//
// public double contradiction(Annotation a1, Annotation a2) {
// double d = probability(a1, a2);
// if (d == 0)
// return 0;
// if (d < 0)
// return Math.abs(d);
// return 0.0;
// }
//
// @Override
// public abstract RulesSource clone();
//
// public double entails(Annotation a1, Annotation a2) {
// double d = probability(a1, a2);
// if (d == 0)
// return 0;
// if (d > 0)
// return d;
// return 0.0;
// }
//
// public abstract List<Rule> extractRules(AnnotatedText t, AnnotatedText h);
//
// public abstract double probability(Annotation a1, Annotation a2);
//
// public abstract Set<String> uses();
//
// }
// Path: edits-core/src/main/java/org/edits/distance/match/SimpleRulesMatcher.java
import lombok.Data;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import org.edits.rules.RulesSource;
package org.edits.distance.match;
@Data
public class SimpleRulesMatcher implements NestedMatcher {
private static final long serialVersionUID = 1L;
private final Matcher matcher;
private final RulesSource source;
public SimpleRulesMatcher(Matcher matcher_, RulesSource source_) {
source = source_;
matcher = matcher_;
}
public SimpleRulesMatcher(RulesSource source_) {
source = source_;
matcher = new DefaultMatcher();
}
@Override
public Matcher copy() {
return new SimpleRulesMatcher(matcher.copy(), source.clone());
}
@Override | public double match(Annotation node1, Annotation node2, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-server/src/main/java/org/edits/rest/EngineInstance.java | // Path: edits-core/src/main/java/org/edits/EditsTextAnnotator.java
// public interface EditsTextAnnotator {
//
// public List<Annotation> annotate(String text) throws Exception;
//
// }
//
// Path: edits-core/src/main/java/org/edits/EntailmentEngineModel.java
// @Data
// public class EntailmentEngineModel implements Serializable {
// /**
// *
// */
// private static final long serialVersionUID = -5993904733998446064L;
// private String anotator;
// private EntailmentEngine engine;
// private EvaluationStatistics statistics;
//
// public EntailmentEngineModel() {
//
// }
//
// public EntailmentEngineModel(String anotator, EntailmentEngine engine, EvaluationStatistics statistics) {
// super();
// this.anotator = anotator;
// this.engine = engine;
// this.statistics = statistics;
// }
//
// }
| import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.EditsTextAnnotator;
import org.edits.EntailmentEngineModel; | package org.edits.rest;
@Data
@EqualsAndHashCode(callSuper = false)
public class EngineInstance {
public enum Status {
FAIL, NOT_FOUND, ONLINE, TRAINING
}
| // Path: edits-core/src/main/java/org/edits/EditsTextAnnotator.java
// public interface EditsTextAnnotator {
//
// public List<Annotation> annotate(String text) throws Exception;
//
// }
//
// Path: edits-core/src/main/java/org/edits/EntailmentEngineModel.java
// @Data
// public class EntailmentEngineModel implements Serializable {
// /**
// *
// */
// private static final long serialVersionUID = -5993904733998446064L;
// private String anotator;
// private EntailmentEngine engine;
// private EvaluationStatistics statistics;
//
// public EntailmentEngineModel() {
//
// }
//
// public EntailmentEngineModel(String anotator, EntailmentEngine engine, EvaluationStatistics statistics) {
// super();
// this.anotator = anotator;
// this.engine = engine;
// this.statistics = statistics;
// }
//
// }
// Path: edits-server/src/main/java/org/edits/rest/EngineInstance.java
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.EditsTextAnnotator;
import org.edits.EntailmentEngineModel;
package org.edits.rest;
@Data
@EqualsAndHashCode(callSuper = false)
public class EngineInstance {
public enum Status {
FAIL, NOT_FOUND, ONLINE, TRAINING
}
| private EditsTextAnnotator annotator; |
kouylekov/edits | edits-server/src/main/java/org/edits/rest/EngineInstance.java | // Path: edits-core/src/main/java/org/edits/EditsTextAnnotator.java
// public interface EditsTextAnnotator {
//
// public List<Annotation> annotate(String text) throws Exception;
//
// }
//
// Path: edits-core/src/main/java/org/edits/EntailmentEngineModel.java
// @Data
// public class EntailmentEngineModel implements Serializable {
// /**
// *
// */
// private static final long serialVersionUID = -5993904733998446064L;
// private String anotator;
// private EntailmentEngine engine;
// private EvaluationStatistics statistics;
//
// public EntailmentEngineModel() {
//
// }
//
// public EntailmentEngineModel(String anotator, EntailmentEngine engine, EvaluationStatistics statistics) {
// super();
// this.anotator = anotator;
// this.engine = engine;
// this.statistics = statistics;
// }
//
// }
| import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.EditsTextAnnotator;
import org.edits.EntailmentEngineModel; | package org.edits.rest;
@Data
@EqualsAndHashCode(callSuper = false)
public class EngineInstance {
public enum Status {
FAIL, NOT_FOUND, ONLINE, TRAINING
}
private EditsTextAnnotator annotator;
private final String id; | // Path: edits-core/src/main/java/org/edits/EditsTextAnnotator.java
// public interface EditsTextAnnotator {
//
// public List<Annotation> annotate(String text) throws Exception;
//
// }
//
// Path: edits-core/src/main/java/org/edits/EntailmentEngineModel.java
// @Data
// public class EntailmentEngineModel implements Serializable {
// /**
// *
// */
// private static final long serialVersionUID = -5993904733998446064L;
// private String anotator;
// private EntailmentEngine engine;
// private EvaluationStatistics statistics;
//
// public EntailmentEngineModel() {
//
// }
//
// public EntailmentEngineModel(String anotator, EntailmentEngine engine, EvaluationStatistics statistics) {
// super();
// this.anotator = anotator;
// this.engine = engine;
// this.statistics = statistics;
// }
//
// }
// Path: edits-server/src/main/java/org/edits/rest/EngineInstance.java
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.EditsTextAnnotator;
import org.edits.EntailmentEngineModel;
package org.edits.rest;
@Data
@EqualsAndHashCode(callSuper = false)
public class EngineInstance {
public enum Status {
FAIL, NOT_FOUND, ONLINE, TRAINING
}
private EditsTextAnnotator annotator;
private final String id; | private EntailmentEngineModel model; |
kouylekov/edits | edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java | // Path: edits-core/src/main/java/org/edits/EditsTextAnnotator.java
// public interface EditsTextAnnotator {
//
// public List<Annotation> annotate(String text) throws Exception;
//
// }
| import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import lombok.Data;
import org.edits.EditsTextAnnotator;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps; | package org.edits.etaf;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
public class AnnotatedEntailmentPair {
| // Path: edits-core/src/main/java/org/edits/EditsTextAnnotator.java
// public interface EditsTextAnnotator {
//
// public List<Annotation> annotate(String text) throws Exception;
//
// }
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import lombok.Data;
import org.edits.EditsTextAnnotator;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
package org.edits.etaf;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
public class AnnotatedEntailmentPair {
| public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception { |
kouylekov/edits | edits-core/src/main/java/org/edits/rules/RulesIndexGenerator.java | // Path: edits-core/src/main/java/org/edits/engines/thread/EditsThread.java
// @Log4j
// public abstract class EditsThread<E> {
//
// private boolean finnished = false;
// private Iterator<E> iterator;
// @Getter
// @Setter
// private int threads;
// private int workers = 0;
//
// public EditsThread() {
// Runtime runtime = Runtime.getRuntime();
// threads = runtime.availableProcessors();
// if (threads > 24)
// threads = 24;
// }
//
// public EditsThread(int threads_) {
// threads = threads_;
// }
//
// public synchronized void finnished() {
// workers--;
// if (workers == 0) {
// finnished = true;
// }
// }
//
// public synchronized void increment() {
// workers++;
// }
//
// /**
// * @return
// * @throws Exception
// */
// public synchronized E next() throws Exception {
//
// if (iterator != null && iterator.hasNext())
// return iterator.next();
// return null;
// }
//
// public abstract void process(E object) throws Exception;
//
// public void start(Iterator<E> iterator_) {
// iterator = iterator_;
// log.debug("Started with " + threads + " threads");
// for (int i = 0; i < threads; i++)
// new Worker<E>(this).start();
// finnished = false;
// try {
// while (finnished == false)
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// }
// iterator = null;
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import lombok.extern.log4j.Log4j;
import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field.Store;
import org.apache.lucene.document.StringField;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.Version;
import org.edits.engines.thread.EditsThread;
import org.edits.etaf.AnnotatedEntailmentPair;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Sets; | package org.edits.rules;
@Log4j
public class RulesIndexGenerator extends EditsThread<AnnotatedEntailmentPair> {
private final Set<String> cache;
private final boolean extractRules;
private final RulesSource rulesSource;
private IndexWriter writer;
public RulesIndexGenerator(RulesSource rulesSource_, boolean extractRules_) {
cache = Sets.newHashSet();
rulesSource = rulesSource_;
extractRules = extractRules_;
}
| // Path: edits-core/src/main/java/org/edits/engines/thread/EditsThread.java
// @Log4j
// public abstract class EditsThread<E> {
//
// private boolean finnished = false;
// private Iterator<E> iterator;
// @Getter
// @Setter
// private int threads;
// private int workers = 0;
//
// public EditsThread() {
// Runtime runtime = Runtime.getRuntime();
// threads = runtime.availableProcessors();
// if (threads > 24)
// threads = 24;
// }
//
// public EditsThread(int threads_) {
// threads = threads_;
// }
//
// public synchronized void finnished() {
// workers--;
// if (workers == 0) {
// finnished = true;
// }
// }
//
// public synchronized void increment() {
// workers++;
// }
//
// /**
// * @return
// * @throws Exception
// */
// public synchronized E next() throws Exception {
//
// if (iterator != null && iterator.hasNext())
// return iterator.next();
// return null;
// }
//
// public abstract void process(E object) throws Exception;
//
// public void start(Iterator<E> iterator_) {
// iterator = iterator_;
// log.debug("Started with " + threads + " threads");
// for (int i = 0; i < threads; i++)
// new Worker<E>(this).start();
// finnished = false;
// try {
// while (finnished == false)
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// }
// iterator = null;
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/rules/RulesIndexGenerator.java
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import lombok.extern.log4j.Log4j;
import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field.Store;
import org.apache.lucene.document.StringField;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.Version;
import org.edits.engines.thread.EditsThread;
import org.edits.etaf.AnnotatedEntailmentPair;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Sets;
package org.edits.rules;
@Log4j
public class RulesIndexGenerator extends EditsThread<AnnotatedEntailmentPair> {
private final Set<String> cache;
private final boolean extractRules;
private final RulesSource rulesSource;
private IndexWriter writer;
public RulesIndexGenerator(RulesSource rulesSource_, boolean extractRules_) {
cache = Sets.newHashSet();
rulesSource = rulesSource_;
extractRules = extractRules_;
}
| private void addRule(Annotation at, Annotation ah) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/Rouge.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.util.Arrays;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class Rouge extends EditDistanceAlgorithm {
public enum Type {
L, S, W
}
private static final long serialVersionUID = 1L;
private static double combinationsN2(int n) {
return n * (n - 1) / 2.0;
}
private double beta = 1;
private Type type;
@Override
public EditDistanceAlgorithm clone() {
Rouge r = (Rouge) defaultCopy();
r.setType(type);
r.setBeta(beta);
return r;
}
public double distance(double score, double size1, double size2) {
double precision = score / size2;
double recall = score / size1;
double distance = (1.0 + beta * beta) * (precision * recall) / (recall + beta * beta * precision);
return 1 - distance;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/Rouge.java
import java.util.Arrays;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class Rouge extends EditDistanceAlgorithm {
public enum Type {
L, S, W
}
private static final long serialVersionUID = 1L;
private static double combinationsN2(int n) {
return n * (n - 1) / 2.0;
}
private double beta = 1;
private Type type;
@Override
public EditDistanceAlgorithm clone() {
Rouge r = (Rouge) defaultCopy();
r.setType(type);
r.setBeta(beta);
return r;
}
public double distance(double score, double size1, double size2) {
double precision = score / size2;
double recall = score / size1;
double distance = (1.0 + beta * beta) * (precision * recall) / (recall + beta * beta * precision);
return 1 - distance;
}
@Override | public double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/Rouge.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.util.Arrays;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class Rouge extends EditDistanceAlgorithm {
public enum Type {
L, S, W
}
private static final long serialVersionUID = 1L;
private static double combinationsN2(int n) {
return n * (n - 1) / 2.0;
}
private double beta = 1;
private Type type;
@Override
public EditDistanceAlgorithm clone() {
Rouge r = (Rouge) defaultCopy();
r.setType(type);
r.setBeta(beta);
return r;
}
public double distance(double score, double size1, double size2) {
double precision = score / size2;
double recall = score / size1;
double distance = (1.0 + beta * beta) * (precision * recall) / (recall + beta * beta * precision);
return 1 - distance;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/Rouge.java
import java.util.Arrays;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class Rouge extends EditDistanceAlgorithm {
public enum Type {
L, S, W
}
private static final long serialVersionUID = 1L;
private static double combinationsN2(int n) {
return n * (n - 1) / 2.0;
}
private double beta = 1;
private Type type;
@Override
public EditDistanceAlgorithm clone() {
Rouge r = (Rouge) defaultCopy();
r.setType(type);
r.setBeta(beta);
return r;
}
public double distance(double score, double size1, double size2) {
double precision = score / size2;
double recall = score / size1;
double distance = (1.0 + beta * beta) * (precision * recall) / (recall + beta * beta * precision);
return 1 - distance;
}
@Override | public double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-genetic/src/main/java/org/edits/genetic/OptimizeDistance.java | // Path: edits-core/src/main/java/org/edits/distance/algorithm/EditDistanceAlgorithm.java
// @Data
// @Log4j
// public abstract class EditDistanceAlgorithm implements Serializable, Cloneable {
//
// private static final long serialVersionUID = 1L;
// private Matcher matcher;
// private boolean normalize;
//
// public EditDistanceAlgorithm() {
// normalize = true;
// matcher = new DefaultMatcher();
// }
//
// @Override
// public abstract EditDistanceAlgorithm clone();
//
// public EditDistanceAlgorithm defaultCopy() {
// EditDistanceAlgorithm a = instance(this.getClass().getName());
// a.setMatcher(getMatcher().copy());
// a.setNormalize(normalize);
// return a;
// }
//
// public double distance(AnnotatedText t, AnnotatedText h, String pairID) {
// List<Annotation> w1 = t.getAnnotation();
// List<Annotation> w2 = h.getAnnotation();
// return distance(w1, w2, t, h, pairID);
// }
//
// public abstract double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h,
// String pairID);
//
// public double init(double dist, double norm) {
// if (!normalize)
// return dist;
// return dist / norm;
// }
//
// public EditDistanceAlgorithm instance(String name) {
// try {
// return (EditDistanceAlgorithm) this.getClass().getClassLoader().loadClass(this.getClass().getName())
// .newInstance();
// } catch (Exception e) {
// log.debug(e);
// throw new RuntimeException("Could not load algorithm " + name);
// }
// }
// }
//
// Path: edits-core/src/main/java/org/edits/engines/thread/EditsThread.java
// @Log4j
// public abstract class EditsThread<E> {
//
// private boolean finnished = false;
// private Iterator<E> iterator;
// @Getter
// @Setter
// private int threads;
// private int workers = 0;
//
// public EditsThread() {
// Runtime runtime = Runtime.getRuntime();
// threads = runtime.availableProcessors();
// if (threads > 24)
// threads = 24;
// }
//
// public EditsThread(int threads_) {
// threads = threads_;
// }
//
// public synchronized void finnished() {
// workers--;
// if (workers == 0) {
// finnished = true;
// }
// }
//
// public synchronized void increment() {
// workers++;
// }
//
// /**
// * @return
// * @throws Exception
// */
// public synchronized E next() throws Exception {
//
// if (iterator != null && iterator.hasNext())
// return iterator.next();
// return null;
// }
//
// public abstract void process(E object) throws Exception;
//
// public void start(Iterator<E> iterator_) {
// iterator = iterator_;
// log.debug("Started with " + threads + " threads");
// for (int i = 0; i < threads; i++)
// new Worker<E>(this).start();
// finnished = false;
// try {
// while (finnished == false)
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// }
// iterator = null;
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
| import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Getter;
import lombok.extern.log4j.Log4j;
import org.edits.distance.algorithm.EditDistanceAlgorithm;
import org.edits.engines.thread.EditsThread;
import org.edits.etaf.AnnotatedEntailmentPair;
import org.jgap.Chromosome;
import org.jgap.Configuration;
import org.jgap.Genotype;
import org.jgap.IChromosome;
import org.jgap.impl.BooleanGene;
import org.jgap.impl.DefaultConfiguration;
import org.jgap.impl.DoubleGene;
import org.jgap.impl.job.MaxFunction;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.AtomicDouble; | package org.edits.genetic;
@Log4j
public class OptimizeDistance extends MaxFunction {
private static final long serialVersionUID = 1L;
| // Path: edits-core/src/main/java/org/edits/distance/algorithm/EditDistanceAlgorithm.java
// @Data
// @Log4j
// public abstract class EditDistanceAlgorithm implements Serializable, Cloneable {
//
// private static final long serialVersionUID = 1L;
// private Matcher matcher;
// private boolean normalize;
//
// public EditDistanceAlgorithm() {
// normalize = true;
// matcher = new DefaultMatcher();
// }
//
// @Override
// public abstract EditDistanceAlgorithm clone();
//
// public EditDistanceAlgorithm defaultCopy() {
// EditDistanceAlgorithm a = instance(this.getClass().getName());
// a.setMatcher(getMatcher().copy());
// a.setNormalize(normalize);
// return a;
// }
//
// public double distance(AnnotatedText t, AnnotatedText h, String pairID) {
// List<Annotation> w1 = t.getAnnotation();
// List<Annotation> w2 = h.getAnnotation();
// return distance(w1, w2, t, h, pairID);
// }
//
// public abstract double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h,
// String pairID);
//
// public double init(double dist, double norm) {
// if (!normalize)
// return dist;
// return dist / norm;
// }
//
// public EditDistanceAlgorithm instance(String name) {
// try {
// return (EditDistanceAlgorithm) this.getClass().getClassLoader().loadClass(this.getClass().getName())
// .newInstance();
// } catch (Exception e) {
// log.debug(e);
// throw new RuntimeException("Could not load algorithm " + name);
// }
// }
// }
//
// Path: edits-core/src/main/java/org/edits/engines/thread/EditsThread.java
// @Log4j
// public abstract class EditsThread<E> {
//
// private boolean finnished = false;
// private Iterator<E> iterator;
// @Getter
// @Setter
// private int threads;
// private int workers = 0;
//
// public EditsThread() {
// Runtime runtime = Runtime.getRuntime();
// threads = runtime.availableProcessors();
// if (threads > 24)
// threads = 24;
// }
//
// public EditsThread(int threads_) {
// threads = threads_;
// }
//
// public synchronized void finnished() {
// workers--;
// if (workers == 0) {
// finnished = true;
// }
// }
//
// public synchronized void increment() {
// workers++;
// }
//
// /**
// * @return
// * @throws Exception
// */
// public synchronized E next() throws Exception {
//
// if (iterator != null && iterator.hasNext())
// return iterator.next();
// return null;
// }
//
// public abstract void process(E object) throws Exception;
//
// public void start(Iterator<E> iterator_) {
// iterator = iterator_;
// log.debug("Started with " + threads + " threads");
// for (int i = 0; i < threads; i++)
// new Worker<E>(this).start();
// finnished = false;
// try {
// while (finnished == false)
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// }
// iterator = null;
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
// Path: edits-genetic/src/main/java/org/edits/genetic/OptimizeDistance.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Getter;
import lombok.extern.log4j.Log4j;
import org.edits.distance.algorithm.EditDistanceAlgorithm;
import org.edits.engines.thread.EditsThread;
import org.edits.etaf.AnnotatedEntailmentPair;
import org.jgap.Chromosome;
import org.jgap.Configuration;
import org.jgap.Genotype;
import org.jgap.IChromosome;
import org.jgap.impl.BooleanGene;
import org.jgap.impl.DefaultConfiguration;
import org.jgap.impl.DoubleGene;
import org.jgap.impl.job.MaxFunction;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.AtomicDouble;
package org.edits.genetic;
@Log4j
public class OptimizeDistance extends MaxFunction {
private static final long serialVersionUID = 1L;
| private final EditDistanceAlgorithm algorithm; |
kouylekov/edits | edits-genetic/src/main/java/org/edits/genetic/OptimizeDistance.java | // Path: edits-core/src/main/java/org/edits/distance/algorithm/EditDistanceAlgorithm.java
// @Data
// @Log4j
// public abstract class EditDistanceAlgorithm implements Serializable, Cloneable {
//
// private static final long serialVersionUID = 1L;
// private Matcher matcher;
// private boolean normalize;
//
// public EditDistanceAlgorithm() {
// normalize = true;
// matcher = new DefaultMatcher();
// }
//
// @Override
// public abstract EditDistanceAlgorithm clone();
//
// public EditDistanceAlgorithm defaultCopy() {
// EditDistanceAlgorithm a = instance(this.getClass().getName());
// a.setMatcher(getMatcher().copy());
// a.setNormalize(normalize);
// return a;
// }
//
// public double distance(AnnotatedText t, AnnotatedText h, String pairID) {
// List<Annotation> w1 = t.getAnnotation();
// List<Annotation> w2 = h.getAnnotation();
// return distance(w1, w2, t, h, pairID);
// }
//
// public abstract double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h,
// String pairID);
//
// public double init(double dist, double norm) {
// if (!normalize)
// return dist;
// return dist / norm;
// }
//
// public EditDistanceAlgorithm instance(String name) {
// try {
// return (EditDistanceAlgorithm) this.getClass().getClassLoader().loadClass(this.getClass().getName())
// .newInstance();
// } catch (Exception e) {
// log.debug(e);
// throw new RuntimeException("Could not load algorithm " + name);
// }
// }
// }
//
// Path: edits-core/src/main/java/org/edits/engines/thread/EditsThread.java
// @Log4j
// public abstract class EditsThread<E> {
//
// private boolean finnished = false;
// private Iterator<E> iterator;
// @Getter
// @Setter
// private int threads;
// private int workers = 0;
//
// public EditsThread() {
// Runtime runtime = Runtime.getRuntime();
// threads = runtime.availableProcessors();
// if (threads > 24)
// threads = 24;
// }
//
// public EditsThread(int threads_) {
// threads = threads_;
// }
//
// public synchronized void finnished() {
// workers--;
// if (workers == 0) {
// finnished = true;
// }
// }
//
// public synchronized void increment() {
// workers++;
// }
//
// /**
// * @return
// * @throws Exception
// */
// public synchronized E next() throws Exception {
//
// if (iterator != null && iterator.hasNext())
// return iterator.next();
// return null;
// }
//
// public abstract void process(E object) throws Exception;
//
// public void start(Iterator<E> iterator_) {
// iterator = iterator_;
// log.debug("Started with " + threads + " threads");
// for (int i = 0; i < threads; i++)
// new Worker<E>(this).start();
// finnished = false;
// try {
// while (finnished == false)
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// }
// iterator = null;
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
| import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Getter;
import lombok.extern.log4j.Log4j;
import org.edits.distance.algorithm.EditDistanceAlgorithm;
import org.edits.engines.thread.EditsThread;
import org.edits.etaf.AnnotatedEntailmentPair;
import org.jgap.Chromosome;
import org.jgap.Configuration;
import org.jgap.Genotype;
import org.jgap.IChromosome;
import org.jgap.impl.BooleanGene;
import org.jgap.impl.DefaultConfiguration;
import org.jgap.impl.DoubleGene;
import org.jgap.impl.job.MaxFunction;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.AtomicDouble; | package org.edits.genetic;
@Log4j
public class OptimizeDistance extends MaxFunction {
private static final long serialVersionUID = 1L;
private final EditDistanceAlgorithm algorithm;
private Map<String, Double> cache;
@Getter
private final AlgorithmInitializator initializator;
private final int iterations;
private GeneticResult result;
private List<GeneticResult> results; | // Path: edits-core/src/main/java/org/edits/distance/algorithm/EditDistanceAlgorithm.java
// @Data
// @Log4j
// public abstract class EditDistanceAlgorithm implements Serializable, Cloneable {
//
// private static final long serialVersionUID = 1L;
// private Matcher matcher;
// private boolean normalize;
//
// public EditDistanceAlgorithm() {
// normalize = true;
// matcher = new DefaultMatcher();
// }
//
// @Override
// public abstract EditDistanceAlgorithm clone();
//
// public EditDistanceAlgorithm defaultCopy() {
// EditDistanceAlgorithm a = instance(this.getClass().getName());
// a.setMatcher(getMatcher().copy());
// a.setNormalize(normalize);
// return a;
// }
//
// public double distance(AnnotatedText t, AnnotatedText h, String pairID) {
// List<Annotation> w1 = t.getAnnotation();
// List<Annotation> w2 = h.getAnnotation();
// return distance(w1, w2, t, h, pairID);
// }
//
// public abstract double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h,
// String pairID);
//
// public double init(double dist, double norm) {
// if (!normalize)
// return dist;
// return dist / norm;
// }
//
// public EditDistanceAlgorithm instance(String name) {
// try {
// return (EditDistanceAlgorithm) this.getClass().getClassLoader().loadClass(this.getClass().getName())
// .newInstance();
// } catch (Exception e) {
// log.debug(e);
// throw new RuntimeException("Could not load algorithm " + name);
// }
// }
// }
//
// Path: edits-core/src/main/java/org/edits/engines/thread/EditsThread.java
// @Log4j
// public abstract class EditsThread<E> {
//
// private boolean finnished = false;
// private Iterator<E> iterator;
// @Getter
// @Setter
// private int threads;
// private int workers = 0;
//
// public EditsThread() {
// Runtime runtime = Runtime.getRuntime();
// threads = runtime.availableProcessors();
// if (threads > 24)
// threads = 24;
// }
//
// public EditsThread(int threads_) {
// threads = threads_;
// }
//
// public synchronized void finnished() {
// workers--;
// if (workers == 0) {
// finnished = true;
// }
// }
//
// public synchronized void increment() {
// workers++;
// }
//
// /**
// * @return
// * @throws Exception
// */
// public synchronized E next() throws Exception {
//
// if (iterator != null && iterator.hasNext())
// return iterator.next();
// return null;
// }
//
// public abstract void process(E object) throws Exception;
//
// public void start(Iterator<E> iterator_) {
// iterator = iterator_;
// log.debug("Started with " + threads + " threads");
// for (int i = 0; i < threads; i++)
// new Worker<E>(this).start();
// finnished = false;
// try {
// while (finnished == false)
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// }
// iterator = null;
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
// Path: edits-genetic/src/main/java/org/edits/genetic/OptimizeDistance.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Getter;
import lombok.extern.log4j.Log4j;
import org.edits.distance.algorithm.EditDistanceAlgorithm;
import org.edits.engines.thread.EditsThread;
import org.edits.etaf.AnnotatedEntailmentPair;
import org.jgap.Chromosome;
import org.jgap.Configuration;
import org.jgap.Genotype;
import org.jgap.IChromosome;
import org.jgap.impl.BooleanGene;
import org.jgap.impl.DefaultConfiguration;
import org.jgap.impl.DoubleGene;
import org.jgap.impl.job.MaxFunction;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.AtomicDouble;
package org.edits.genetic;
@Log4j
public class OptimizeDistance extends MaxFunction {
private static final long serialVersionUID = 1L;
private final EditDistanceAlgorithm algorithm;
private Map<String, Double> cache;
@Getter
private final AlgorithmInitializator initializator;
private final int iterations;
private GeneticResult result;
private List<GeneticResult> results; | private final List<AnnotatedEntailmentPair> training; |
kouylekov/edits | edits-core/src/main/java/org/edits/engines/thread/ThreadTrainedEngine.java | // Path: edits-core/src/main/java/org/edits/engines/EntailmentEngine.java
// @Data
// public abstract class EntailmentEngine implements Serializable {
// /**
// *
// */
// private static final long serialVersionUID = 1L;
// private OptimizationGoal goal;
//
// public abstract EvaluationResult evaluate(AnnotatedEntailmentPair p);
//
// public void setDefaultGoal() {
// goal = new OptimizationGoal();
// }
//
// public abstract EvaluationStatistics train(List<AnnotatedEntailmentPair> processor) throws Exception;
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
| import org.edits.engines.EntailmentEngine;
import org.edits.etaf.AnnotatedEntailmentPair; | package org.edits.engines.thread;
public abstract class ThreadTrainedEngine extends EntailmentEngine {
private static final long serialVersionUID = 1L;
| // Path: edits-core/src/main/java/org/edits/engines/EntailmentEngine.java
// @Data
// public abstract class EntailmentEngine implements Serializable {
// /**
// *
// */
// private static final long serialVersionUID = 1L;
// private OptimizationGoal goal;
//
// public abstract EvaluationResult evaluate(AnnotatedEntailmentPair p);
//
// public void setDefaultGoal() {
// goal = new OptimizationGoal();
// }
//
// public abstract EvaluationStatistics train(List<AnnotatedEntailmentPair> processor) throws Exception;
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
// Path: edits-core/src/main/java/org/edits/engines/thread/ThreadTrainedEngine.java
import org.edits.engines.EntailmentEngine;
import org.edits.etaf.AnnotatedEntailmentPair;
package org.edits.engines.thread;
public abstract class ThreadTrainedEngine extends EntailmentEngine {
private static final long serialVersionUID = 1L;
| public abstract void handle(AnnotatedEntailmentPair p); |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/weight/PosWeight.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation; | package org.edits.distance.weight;
public class PosWeight implements NamedWeightCalculator {
public static final String ADJECTIVE = "adj";
public static final String NOUN = "noun";
private static final long serialVersionUID = 1L;
public static final String VERB = "verb";
public static PosWeight posWeightAdjective() {
return new PosWeight(ADJECTIVE);
}
public static PosWeight posWeightNoun() {
return new PosWeight(NOUN);
}
public static PosWeight posWeightVerb() {
return new PosWeight(VERB);
}
private final String pos;
private PosWeight(String pos) {
super();
this.pos = pos;
}
@Override
public WeightCalculator clone() {
return new PosWeight(pos);
}
@Override
public String name() {
return pos;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/weight/PosWeight.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
package org.edits.distance.weight;
public class PosWeight implements NamedWeightCalculator {
public static final String ADJECTIVE = "adj";
public static final String NOUN = "noun";
private static final long serialVersionUID = 1L;
public static final String VERB = "verb";
public static PosWeight posWeightAdjective() {
return new PosWeight(ADJECTIVE);
}
public static PosWeight posWeightNoun() {
return new PosWeight(NOUN);
}
public static PosWeight posWeightVerb() {
return new PosWeight(VERB);
}
private final String pos;
private PosWeight(String pos) {
super();
this.pos = pos;
}
@Override
public WeightCalculator clone() {
return new PosWeight(pos);
}
@Override
public String name() {
return pos;
}
@Override | public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/weight/PosWeight.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation; | package org.edits.distance.weight;
public class PosWeight implements NamedWeightCalculator {
public static final String ADJECTIVE = "adj";
public static final String NOUN = "noun";
private static final long serialVersionUID = 1L;
public static final String VERB = "verb";
public static PosWeight posWeightAdjective() {
return new PosWeight(ADJECTIVE);
}
public static PosWeight posWeightNoun() {
return new PosWeight(NOUN);
}
public static PosWeight posWeightVerb() {
return new PosWeight(VERB);
}
private final String pos;
private PosWeight(String pos) {
super();
this.pos = pos;
}
@Override
public WeightCalculator clone() {
return new PosWeight(pos);
}
@Override
public String name() {
return pos;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/weight/PosWeight.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
package org.edits.distance.weight;
public class PosWeight implements NamedWeightCalculator {
public static final String ADJECTIVE = "adj";
public static final String NOUN = "noun";
private static final long serialVersionUID = 1L;
public static final String VERB = "verb";
public static PosWeight posWeightAdjective() {
return new PosWeight(ADJECTIVE);
}
public static PosWeight posWeightNoun() {
return new PosWeight(NOUN);
}
public static PosWeight posWeightVerb() {
return new PosWeight(VERB);
}
private final String pos;
private PosWeight(String pos) {
super();
this.pos = pos;
}
@Override
public WeightCalculator clone() {
return new PosWeight(pos);
}
@Override
public String name() {
return pos;
}
@Override | public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/WeightedAlgorithm.java | // Path: edits-core/src/main/java/org/edits/distance/weight/DefaultWeightCalculator.java
// @Data
// @EqualsAndHashCode(callSuper = false)
// public class DefaultWeightCalculator implements WeightCalculator {
// public static final long serialVersionUID = 1L;
// private double valueH;
// private double valueT;
//
// public DefaultWeightCalculator() {
// valueH = 1;
// valueT = 1;
// }
//
// @Override
// public WeightCalculator clone() {
// DefaultWeightCalculator dc = new DefaultWeightCalculator();
// dc.setValueH(valueH);
// dc.setValueT(valueT);
// return dc;
// }
//
// @Override
// public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) {
// return valueH;
// }
//
// @Override
// public double weightT(Annotation node, AnnotatedText t, AnnotatedText h) {
// return valueT;
// }
// }
//
// Path: edits-core/src/main/java/org/edits/distance/weight/WeightCalculator.java
// public interface WeightCalculator extends Serializable, Cloneable {
//
// public double weightH(Annotation node, AnnotatedText t, AnnotatedText h);
//
// public double weightT(Annotation node, AnnotatedText t, AnnotatedText h);
//
// public WeightCalculator clone();
//
// }
| import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.distance.weight.DefaultWeightCalculator;
import org.edits.distance.weight.WeightCalculator; | package org.edits.distance.algorithm;
@Data
@EqualsAndHashCode(callSuper = false)
public abstract class WeightedAlgorithm extends EditDistanceAlgorithm {
private static final long serialVersionUID = 1L;
| // Path: edits-core/src/main/java/org/edits/distance/weight/DefaultWeightCalculator.java
// @Data
// @EqualsAndHashCode(callSuper = false)
// public class DefaultWeightCalculator implements WeightCalculator {
// public static final long serialVersionUID = 1L;
// private double valueH;
// private double valueT;
//
// public DefaultWeightCalculator() {
// valueH = 1;
// valueT = 1;
// }
//
// @Override
// public WeightCalculator clone() {
// DefaultWeightCalculator dc = new DefaultWeightCalculator();
// dc.setValueH(valueH);
// dc.setValueT(valueT);
// return dc;
// }
//
// @Override
// public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) {
// return valueH;
// }
//
// @Override
// public double weightT(Annotation node, AnnotatedText t, AnnotatedText h) {
// return valueT;
// }
// }
//
// Path: edits-core/src/main/java/org/edits/distance/weight/WeightCalculator.java
// public interface WeightCalculator extends Serializable, Cloneable {
//
// public double weightH(Annotation node, AnnotatedText t, AnnotatedText h);
//
// public double weightT(Annotation node, AnnotatedText t, AnnotatedText h);
//
// public WeightCalculator clone();
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/WeightedAlgorithm.java
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.distance.weight.DefaultWeightCalculator;
import org.edits.distance.weight.WeightCalculator;
package org.edits.distance.algorithm;
@Data
@EqualsAndHashCode(callSuper = false)
public abstract class WeightedAlgorithm extends EditDistanceAlgorithm {
private static final long serialVersionUID = 1L;
| private WeightCalculator weightCalculator; |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/WeightedAlgorithm.java | // Path: edits-core/src/main/java/org/edits/distance/weight/DefaultWeightCalculator.java
// @Data
// @EqualsAndHashCode(callSuper = false)
// public class DefaultWeightCalculator implements WeightCalculator {
// public static final long serialVersionUID = 1L;
// private double valueH;
// private double valueT;
//
// public DefaultWeightCalculator() {
// valueH = 1;
// valueT = 1;
// }
//
// @Override
// public WeightCalculator clone() {
// DefaultWeightCalculator dc = new DefaultWeightCalculator();
// dc.setValueH(valueH);
// dc.setValueT(valueT);
// return dc;
// }
//
// @Override
// public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) {
// return valueH;
// }
//
// @Override
// public double weightT(Annotation node, AnnotatedText t, AnnotatedText h) {
// return valueT;
// }
// }
//
// Path: edits-core/src/main/java/org/edits/distance/weight/WeightCalculator.java
// public interface WeightCalculator extends Serializable, Cloneable {
//
// public double weightH(Annotation node, AnnotatedText t, AnnotatedText h);
//
// public double weightT(Annotation node, AnnotatedText t, AnnotatedText h);
//
// public WeightCalculator clone();
//
// }
| import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.distance.weight.DefaultWeightCalculator;
import org.edits.distance.weight.WeightCalculator; | package org.edits.distance.algorithm;
@Data
@EqualsAndHashCode(callSuper = false)
public abstract class WeightedAlgorithm extends EditDistanceAlgorithm {
private static final long serialVersionUID = 1L;
private WeightCalculator weightCalculator;
public WeightedAlgorithm() {
super(); | // Path: edits-core/src/main/java/org/edits/distance/weight/DefaultWeightCalculator.java
// @Data
// @EqualsAndHashCode(callSuper = false)
// public class DefaultWeightCalculator implements WeightCalculator {
// public static final long serialVersionUID = 1L;
// private double valueH;
// private double valueT;
//
// public DefaultWeightCalculator() {
// valueH = 1;
// valueT = 1;
// }
//
// @Override
// public WeightCalculator clone() {
// DefaultWeightCalculator dc = new DefaultWeightCalculator();
// dc.setValueH(valueH);
// dc.setValueT(valueT);
// return dc;
// }
//
// @Override
// public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) {
// return valueH;
// }
//
// @Override
// public double weightT(Annotation node, AnnotatedText t, AnnotatedText h) {
// return valueT;
// }
// }
//
// Path: edits-core/src/main/java/org/edits/distance/weight/WeightCalculator.java
// public interface WeightCalculator extends Serializable, Cloneable {
//
// public double weightH(Annotation node, AnnotatedText t, AnnotatedText h);
//
// public double weightT(Annotation node, AnnotatedText t, AnnotatedText h);
//
// public WeightCalculator clone();
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/WeightedAlgorithm.java
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.edits.distance.weight.DefaultWeightCalculator;
import org.edits.distance.weight.WeightCalculator;
package org.edits.distance.algorithm;
@Data
@EqualsAndHashCode(callSuper = false)
public abstract class WeightedAlgorithm extends EditDistanceAlgorithm {
private static final long serialVersionUID = 1L;
private WeightCalculator weightCalculator;
public WeightedAlgorithm() {
super(); | weightCalculator = new DefaultWeightCalculator(); |
kouylekov/edits | edits-core/src/main/java/org/edits/engines/weka/features/TaskFeature.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
| import java.util.List;
import org.edits.etaf.AnnotatedEntailmentPair; | package org.edits.engines.weka.features;
public class TaskFeature extends Feature {
private static final long serialVersionUID = 1L;
private List<String> tasknames;
@Override
public Feature clone() {
return new TaskFeature();
}
@Override
public boolean isNumeric() {
return false;
}
@Override
public String name() {
return "task";
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
// Path: edits-core/src/main/java/org/edits/engines/weka/features/TaskFeature.java
import java.util.List;
import org.edits.etaf.AnnotatedEntailmentPair;
package org.edits.engines.weka.features;
public class TaskFeature extends Feature {
private static final long serialVersionUID = 1L;
private List<String> tasknames;
@Override
public Feature clone() {
return new TaskFeature();
}
@Override
public boolean isNumeric() {
return false;
}
@Override
public String name() {
return "task";
}
@Override | public String stringValue(AnnotatedEntailmentPair pair) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/CosineSimilarity.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import java.util.List; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class CosineSimilarity extends WeightedAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/CosineSimilarity.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import java.util.List;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class CosineSimilarity extends WeightedAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | public double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/CosineSimilarity.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import java.util.List; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class CosineSimilarity extends WeightedAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/CosineSimilarity.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import java.util.List;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class CosineSimilarity extends WeightedAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | public double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-core/src/main/java/org/edits/engines/weka/features/Feature.java | // Path: edits-core/src/main/java/org/edits/engines/OptimizationGoal.java
// @ToString(includeFieldNames = true)
// public class OptimizationGoal implements Serializable {
//
// public enum Target {
// ACCURACY, FMEASURE, PRECISION, RECALL
// }
//
// public static final OptimizationGoal ACCURACY = new OptimizationGoal(Target.ACCURACY, null);
//
// public static final OptimizationGoal FMEASURE_NO = new OptimizationGoal(Target.FMEASURE, "NO");
// public static final OptimizationGoal FMEASURE_YES = new OptimizationGoal(Target.FMEASURE, "YES");
// public static final OptimizationGoal PRECISION_NO = new OptimizationGoal(Target.PRECISION, "NO");
// public static final OptimizationGoal PRECISION_YES = new OptimizationGoal(Target.PRECISION, "YES");
// public static final OptimizationGoal RECALL_NO = new OptimizationGoal(Target.RECALL, "NO");
// public static final OptimizationGoal RECALL_YES = new OptimizationGoal(Target.RECALL, "YES");
//
// private static final long serialVersionUID = 1L;
//
// @Getter
// private final String relation;
// @Getter
// private final Target target;
//
// public OptimizationGoal() {
// this(Target.ACCURACY, null);
// }
//
// public OptimizationGoal(Target target, String relation) {
// super();
// this.relation = relation;
// this.target = target;
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
| import java.io.Serializable;
import java.util.List;
import org.edits.engines.OptimizationGoal;
import org.edits.etaf.AnnotatedEntailmentPair; | package org.edits.engines.weka.features;
public abstract class Feature implements Serializable, Cloneable {
private static final long serialVersionUID = 1L;
@Override
public abstract Feature clone();
| // Path: edits-core/src/main/java/org/edits/engines/OptimizationGoal.java
// @ToString(includeFieldNames = true)
// public class OptimizationGoal implements Serializable {
//
// public enum Target {
// ACCURACY, FMEASURE, PRECISION, RECALL
// }
//
// public static final OptimizationGoal ACCURACY = new OptimizationGoal(Target.ACCURACY, null);
//
// public static final OptimizationGoal FMEASURE_NO = new OptimizationGoal(Target.FMEASURE, "NO");
// public static final OptimizationGoal FMEASURE_YES = new OptimizationGoal(Target.FMEASURE, "YES");
// public static final OptimizationGoal PRECISION_NO = new OptimizationGoal(Target.PRECISION, "NO");
// public static final OptimizationGoal PRECISION_YES = new OptimizationGoal(Target.PRECISION, "YES");
// public static final OptimizationGoal RECALL_NO = new OptimizationGoal(Target.RECALL, "NO");
// public static final OptimizationGoal RECALL_YES = new OptimizationGoal(Target.RECALL, "YES");
//
// private static final long serialVersionUID = 1L;
//
// @Getter
// private final String relation;
// @Getter
// private final Target target;
//
// public OptimizationGoal() {
// this(Target.ACCURACY, null);
// }
//
// public OptimizationGoal(Target target, String relation) {
// super();
// this.relation = relation;
// this.target = target;
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
// Path: edits-core/src/main/java/org/edits/engines/weka/features/Feature.java
import java.io.Serializable;
import java.util.List;
import org.edits.engines.OptimizationGoal;
import org.edits.etaf.AnnotatedEntailmentPair;
package org.edits.engines.weka.features;
public abstract class Feature implements Serializable, Cloneable {
private static final long serialVersionUID = 1L;
@Override
public abstract Feature clone();
| public double doubleValue(AnnotatedEntailmentPair pair) { |
kouylekov/edits | edits-core/src/main/java/org/edits/engines/weka/features/Feature.java | // Path: edits-core/src/main/java/org/edits/engines/OptimizationGoal.java
// @ToString(includeFieldNames = true)
// public class OptimizationGoal implements Serializable {
//
// public enum Target {
// ACCURACY, FMEASURE, PRECISION, RECALL
// }
//
// public static final OptimizationGoal ACCURACY = new OptimizationGoal(Target.ACCURACY, null);
//
// public static final OptimizationGoal FMEASURE_NO = new OptimizationGoal(Target.FMEASURE, "NO");
// public static final OptimizationGoal FMEASURE_YES = new OptimizationGoal(Target.FMEASURE, "YES");
// public static final OptimizationGoal PRECISION_NO = new OptimizationGoal(Target.PRECISION, "NO");
// public static final OptimizationGoal PRECISION_YES = new OptimizationGoal(Target.PRECISION, "YES");
// public static final OptimizationGoal RECALL_NO = new OptimizationGoal(Target.RECALL, "NO");
// public static final OptimizationGoal RECALL_YES = new OptimizationGoal(Target.RECALL, "YES");
//
// private static final long serialVersionUID = 1L;
//
// @Getter
// private final String relation;
// @Getter
// private final Target target;
//
// public OptimizationGoal() {
// this(Target.ACCURACY, null);
// }
//
// public OptimizationGoal(Target target, String relation) {
// super();
// this.relation = relation;
// this.target = target;
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
| import java.io.Serializable;
import java.util.List;
import org.edits.engines.OptimizationGoal;
import org.edits.etaf.AnnotatedEntailmentPair; | package org.edits.engines.weka.features;
public abstract class Feature implements Serializable, Cloneable {
private static final long serialVersionUID = 1L;
@Override
public abstract Feature clone();
public double doubleValue(AnnotatedEntailmentPair pair) {
throw new UnsupportedOperationException("@Override this method for numeric features.");
}
| // Path: edits-core/src/main/java/org/edits/engines/OptimizationGoal.java
// @ToString(includeFieldNames = true)
// public class OptimizationGoal implements Serializable {
//
// public enum Target {
// ACCURACY, FMEASURE, PRECISION, RECALL
// }
//
// public static final OptimizationGoal ACCURACY = new OptimizationGoal(Target.ACCURACY, null);
//
// public static final OptimizationGoal FMEASURE_NO = new OptimizationGoal(Target.FMEASURE, "NO");
// public static final OptimizationGoal FMEASURE_YES = new OptimizationGoal(Target.FMEASURE, "YES");
// public static final OptimizationGoal PRECISION_NO = new OptimizationGoal(Target.PRECISION, "NO");
// public static final OptimizationGoal PRECISION_YES = new OptimizationGoal(Target.PRECISION, "YES");
// public static final OptimizationGoal RECALL_NO = new OptimizationGoal(Target.RECALL, "NO");
// public static final OptimizationGoal RECALL_YES = new OptimizationGoal(Target.RECALL, "YES");
//
// private static final long serialVersionUID = 1L;
//
// @Getter
// private final String relation;
// @Getter
// private final Target target;
//
// public OptimizationGoal() {
// this(Target.ACCURACY, null);
// }
//
// public OptimizationGoal(Target target, String relation) {
// super();
// this.relation = relation;
// this.target = target;
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
// Path: edits-core/src/main/java/org/edits/engines/weka/features/Feature.java
import java.io.Serializable;
import java.util.List;
import org.edits.engines.OptimizationGoal;
import org.edits.etaf.AnnotatedEntailmentPair;
package org.edits.engines.weka.features;
public abstract class Feature implements Serializable, Cloneable {
private static final long serialVersionUID = 1L;
@Override
public abstract Feature clone();
public double doubleValue(AnnotatedEntailmentPair pair) {
throw new UnsupportedOperationException("@Override this method for numeric features.");
}
| public void init(List<AnnotatedEntailmentPair> training, OptimizationGoal goal) throws Exception { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/weight/WordsIn.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import lombok.Data;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation; | package org.edits.distance.weight;
@Data
public class WordsIn implements NamedWeightCalculator {
private static final long serialVersionUID = 1L;
public static final String WORDS_IN_H = "wordsinh";
public static final String WORDS_IN_T = "wordsint";
public static WordsIn wordsInH() {
return new WordsIn(false);
}
public static WordsIn wordsInT() {
return new WordsIn(true);
}
private boolean inT;
private WordsIn(boolean b) {
inT = b;
}
@Override
public WeightCalculator clone() {
return new WordsIn(inT);
}
@Override
public String name() {
return inT ? WORDS_IN_T : WORDS_IN_H;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/weight/WordsIn.java
import lombok.Data;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
package org.edits.distance.weight;
@Data
public class WordsIn implements NamedWeightCalculator {
private static final long serialVersionUID = 1L;
public static final String WORDS_IN_H = "wordsinh";
public static final String WORDS_IN_T = "wordsint";
public static WordsIn wordsInH() {
return new WordsIn(false);
}
public static WordsIn wordsInT() {
return new WordsIn(true);
}
private boolean inT;
private WordsIn(boolean b) {
inT = b;
}
@Override
public WeightCalculator clone() {
return new WordsIn(inT);
}
@Override
public String name() {
return inT ? WORDS_IN_T : WORDS_IN_H;
}
@Override | public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/weight/WordsIn.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import lombok.Data;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation; | package org.edits.distance.weight;
@Data
public class WordsIn implements NamedWeightCalculator {
private static final long serialVersionUID = 1L;
public static final String WORDS_IN_H = "wordsinh";
public static final String WORDS_IN_T = "wordsint";
public static WordsIn wordsInH() {
return new WordsIn(false);
}
public static WordsIn wordsInT() {
return new WordsIn(true);
}
private boolean inT;
private WordsIn(boolean b) {
inT = b;
}
@Override
public WeightCalculator clone() {
return new WordsIn(inT);
}
@Override
public String name() {
return inT ? WORDS_IN_T : WORDS_IN_H;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/weight/WordsIn.java
import lombok.Data;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
package org.edits.distance.weight;
@Data
public class WordsIn implements NamedWeightCalculator {
private static final long serialVersionUID = 1L;
public static final String WORDS_IN_H = "wordsinh";
public static final String WORDS_IN_T = "wordsint";
public static WordsIn wordsInH() {
return new WordsIn(false);
}
public static WordsIn wordsInT() {
return new WordsIn(true);
}
private boolean inT;
private WordsIn(boolean b) {
inT = b;
}
@Override
public WeightCalculator clone() {
return new WordsIn(inT);
}
@Override
public String name() {
return inT ? WORDS_IN_T : WORDS_IN_H;
}
@Override | public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/weight/DefaultWeightCalculator.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import lombok.EqualsAndHashCode;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import lombok.Data; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.weight;
/**
*
* @author Milen Kouylekov
*
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class DefaultWeightCalculator implements WeightCalculator {
public static final long serialVersionUID = 1L;
private double valueH;
private double valueT;
public DefaultWeightCalculator() {
valueH = 1;
valueT = 1;
}
@Override
public WeightCalculator clone() {
DefaultWeightCalculator dc = new DefaultWeightCalculator();
dc.setValueH(valueH);
dc.setValueT(valueT);
return dc;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/weight/DefaultWeightCalculator.java
import lombok.EqualsAndHashCode;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import lombok.Data;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.weight;
/**
*
* @author Milen Kouylekov
*
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class DefaultWeightCalculator implements WeightCalculator {
public static final long serialVersionUID = 1L;
private double valueH;
private double valueT;
public DefaultWeightCalculator() {
valueH = 1;
valueT = 1;
}
@Override
public WeightCalculator clone() {
DefaultWeightCalculator dc = new DefaultWeightCalculator();
dc.setValueH(valueH);
dc.setValueT(valueT);
return dc;
}
@Override | public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/weight/DefaultWeightCalculator.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import lombok.EqualsAndHashCode;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import lombok.Data; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.weight;
/**
*
* @author Milen Kouylekov
*
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class DefaultWeightCalculator implements WeightCalculator {
public static final long serialVersionUID = 1L;
private double valueH;
private double valueT;
public DefaultWeightCalculator() {
valueH = 1;
valueT = 1;
}
@Override
public WeightCalculator clone() {
DefaultWeightCalculator dc = new DefaultWeightCalculator();
dc.setValueH(valueH);
dc.setValueT(valueT);
return dc;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/weight/DefaultWeightCalculator.java
import lombok.EqualsAndHashCode;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import lombok.Data;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.weight;
/**
*
* @author Milen Kouylekov
*
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class DefaultWeightCalculator implements WeightCalculator {
public static final long serialVersionUID = 1L;
private double valueH;
private double valueT;
public DefaultWeightCalculator() {
valueH = 1;
valueT = 1;
}
@Override
public WeightCalculator clone() {
DefaultWeightCalculator dc = new DefaultWeightCalculator();
dc.setValueH(valueH);
dc.setValueT(valueT);
return dc;
}
@Override | public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-core/src/main/java/org/edits/engines/weka/features/NegationFeature.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.util.Set;
import org.edits.etaf.AnnotatedEntailmentPair;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Sets; | package org.edits.engines.weka.features;
public class NegationFeature extends Feature {
/**
*
*/
private static final long serialVersionUID = 1L;
private final Set<String> negativeWords;
public NegationFeature() {
negativeWords = Sets.newHashSet();
negativeWords.add("not");
negativeWords.add("never");
negativeWords.add("no");
}
@Override
public Feature clone() {
return new NegationFeature();
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/engines/weka/features/NegationFeature.java
import java.util.Set;
import org.edits.etaf.AnnotatedEntailmentPair;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Sets;
package org.edits.engines.weka.features;
public class NegationFeature extends Feature {
/**
*
*/
private static final long serialVersionUID = 1L;
private final Set<String> negativeWords;
public NegationFeature() {
negativeWords = Sets.newHashSet();
negativeWords.add("not");
negativeWords.add("never");
negativeWords.add("no");
}
@Override
public Feature clone() {
return new NegationFeature();
}
@Override | public double doubleValue(AnnotatedEntailmentPair pair) { |
kouylekov/edits | edits-core/src/main/java/org/edits/engines/weka/features/NegationFeature.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.util.Set;
import org.edits.etaf.AnnotatedEntailmentPair;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Sets; | package org.edits.engines.weka.features;
public class NegationFeature extends Feature {
/**
*
*/
private static final long serialVersionUID = 1L;
private final Set<String> negativeWords;
public NegationFeature() {
negativeWords = Sets.newHashSet();
negativeWords.add("not");
negativeWords.add("never");
negativeWords.add("no");
}
@Override
public Feature clone() {
return new NegationFeature();
}
@Override
public double doubleValue(AnnotatedEntailmentPair pair) {
int hasNagationinH = 0;
int hasNagationinT = 0;
| // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/engines/weka/features/NegationFeature.java
import java.util.Set;
import org.edits.etaf.AnnotatedEntailmentPair;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Sets;
package org.edits.engines.weka.features;
public class NegationFeature extends Feature {
/**
*
*/
private static final long serialVersionUID = 1L;
private final Set<String> negativeWords;
public NegationFeature() {
negativeWords = Sets.newHashSet();
negativeWords.add("not");
negativeWords.add("never");
negativeWords.add("no");
}
@Override
public Feature clone() {
return new NegationFeature();
}
@Override
public double doubleValue(AnnotatedEntailmentPair pair) {
int hasNagationinH = 0;
int hasNagationinT = 0;
| for (AnnotatedText a : pair.getH()) { |
kouylekov/edits | edits-core/src/main/java/org/edits/engines/weka/features/NegationFeature.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.util.Set;
import org.edits.etaf.AnnotatedEntailmentPair;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Sets; | package org.edits.engines.weka.features;
public class NegationFeature extends Feature {
/**
*
*/
private static final long serialVersionUID = 1L;
private final Set<String> negativeWords;
public NegationFeature() {
negativeWords = Sets.newHashSet();
negativeWords.add("not");
negativeWords.add("never");
negativeWords.add("no");
}
@Override
public Feature clone() {
return new NegationFeature();
}
@Override
public double doubleValue(AnnotatedEntailmentPair pair) {
int hasNagationinH = 0;
int hasNagationinT = 0;
for (AnnotatedText a : pair.getH()) { | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/engines/weka/features/NegationFeature.java
import java.util.Set;
import org.edits.etaf.AnnotatedEntailmentPair;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Sets;
package org.edits.engines.weka.features;
public class NegationFeature extends Feature {
/**
*
*/
private static final long serialVersionUID = 1L;
private final Set<String> negativeWords;
public NegationFeature() {
negativeWords = Sets.newHashSet();
negativeWords.add("not");
negativeWords.add("never");
negativeWords.add("no");
}
@Override
public Feature clone() {
return new NegationFeature();
}
@Override
public double doubleValue(AnnotatedEntailmentPair pair) {
int hasNagationinH = 0;
int hasNagationinT = 0;
for (AnnotatedText a : pair.getH()) { | for (Annotation h : a.getAnnotation()) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/JaroWinkler.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.util.List;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import java.util.Arrays; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class JaroWinkler extends EditDistanceAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/JaroWinkler.java
import java.util.List;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import java.util.Arrays;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class JaroWinkler extends EditDistanceAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | public double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/JaroWinkler.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.util.List;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import java.util.Arrays; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class JaroWinkler extends EditDistanceAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/JaroWinkler.java
import java.util.List;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import java.util.Arrays;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class JaroWinkler extends EditDistanceAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | public double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/weight/NumberWeight.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation; |
public boolean isValue(String s) {
if (!NumberWeight.isNumber(s))
return false;
if (name.equals(NUMBER))
return true;
if (s.indexOf('.') != -1)
return false;
int i = Integer.parseInt(s);
if (name.equals(YEAR))
return true;
if (name.equals(WEEKDAY))
return i <= 1 && i >= 366;
if (name.equals(MONTH))
return i <= 12 && i >= 1;
if (name.equals(MONTHDAY))
return i <= 31 && i >= 1;
if (name.equals(WEEK))
return i <= 52 && i >= 1;
if (name.equals(WEEKDAY))
return i <= 7 && i >= 1;
return false;
}
@Override
public String name() {
return name;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/weight/NumberWeight.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
public boolean isValue(String s) {
if (!NumberWeight.isNumber(s))
return false;
if (name.equals(NUMBER))
return true;
if (s.indexOf('.') != -1)
return false;
int i = Integer.parseInt(s);
if (name.equals(YEAR))
return true;
if (name.equals(WEEKDAY))
return i <= 1 && i >= 366;
if (name.equals(MONTH))
return i <= 12 && i >= 1;
if (name.equals(MONTHDAY))
return i <= 31 && i >= 1;
if (name.equals(WEEK))
return i <= 52 && i >= 1;
if (name.equals(WEEKDAY))
return i <= 7 && i >= 1;
return false;
}
@Override
public String name() {
return name;
}
@Override | public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/weight/NumberWeight.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation; |
public boolean isValue(String s) {
if (!NumberWeight.isNumber(s))
return false;
if (name.equals(NUMBER))
return true;
if (s.indexOf('.') != -1)
return false;
int i = Integer.parseInt(s);
if (name.equals(YEAR))
return true;
if (name.equals(WEEKDAY))
return i <= 1 && i >= 366;
if (name.equals(MONTH))
return i <= 12 && i >= 1;
if (name.equals(MONTHDAY))
return i <= 31 && i >= 1;
if (name.equals(WEEK))
return i <= 52 && i >= 1;
if (name.equals(WEEKDAY))
return i <= 7 && i >= 1;
return false;
}
@Override
public String name() {
return name;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/weight/NumberWeight.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
public boolean isValue(String s) {
if (!NumberWeight.isNumber(s))
return false;
if (name.equals(NUMBER))
return true;
if (s.indexOf('.') != -1)
return false;
int i = Integer.parseInt(s);
if (name.equals(YEAR))
return true;
if (name.equals(WEEKDAY))
return i <= 1 && i >= 366;
if (name.equals(MONTH))
return i <= 12 && i >= 1;
if (name.equals(MONTHDAY))
return i <= 31 && i >= 1;
if (name.equals(WEEK))
return i <= 52 && i >= 1;
if (name.equals(WEEKDAY))
return i <= 7 && i >= 1;
return false;
}
@Override
public String name() {
return name;
}
@Override | public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/weight/SymbolWeight.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation; | package org.edits.distance.weight;
public class SymbolWeight implements NamedWeightCalculator {
private static final long serialVersionUID = 1L;
public static final String SYMBOL = "symbol";
private static boolean isSymbol(String s) {
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if (Character.isLetter(ch) || Character.isDigit(ch))
return false;
}
return true;
}
@Override
public WeightCalculator clone() {
return new SymbolWeight();
}
@Override
public String name() {
return SYMBOL;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/weight/SymbolWeight.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
package org.edits.distance.weight;
public class SymbolWeight implements NamedWeightCalculator {
private static final long serialVersionUID = 1L;
public static final String SYMBOL = "symbol";
private static boolean isSymbol(String s) {
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if (Character.isLetter(ch) || Character.isDigit(ch))
return false;
}
return true;
}
@Override
public WeightCalculator clone() {
return new SymbolWeight();
}
@Override
public String name() {
return SYMBOL;
}
@Override | public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/weight/SymbolWeight.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation; | package org.edits.distance.weight;
public class SymbolWeight implements NamedWeightCalculator {
private static final long serialVersionUID = 1L;
public static final String SYMBOL = "symbol";
private static boolean isSymbol(String s) {
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if (Character.isLetter(ch) || Character.isDigit(ch))
return false;
}
return true;
}
@Override
public WeightCalculator clone() {
return new SymbolWeight();
}
@Override
public String name() {
return SYMBOL;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/weight/SymbolWeight.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
package org.edits.distance.weight;
public class SymbolWeight implements NamedWeightCalculator {
private static final long serialVersionUID = 1L;
public static final String SYMBOL = "symbol";
private static boolean isSymbol(String s) {
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if (Character.isLetter(ch) || Character.isDigit(ch))
return false;
}
return true;
}
@Override
public WeightCalculator clone() {
return new SymbolWeight();
}
@Override
public String name() {
return SYMBOL;
}
@Override | public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/OverlapDistance.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import java.util.List; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class OverlapDistance extends WeightedAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/OverlapDistance.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import java.util.List;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class OverlapDistance extends WeightedAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | public double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/OverlapDistance.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import java.util.List; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class OverlapDistance extends WeightedAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/OverlapDistance.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import java.util.List;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class OverlapDistance extends WeightedAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | public double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-core/src/main/java/org/edits/etaf/EntailmentCorpus.java | // Path: edits-core/src/main/java/org/edits/EditsTextAnnotator.java
// public interface EditsTextAnnotator {
//
// public List<Annotation> annotate(String text) throws Exception;
//
// }
| import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import lombok.Data;
import org.edits.EditsTextAnnotator;
import com.google.common.collect.Lists; | package org.edits.etaf;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "EntailmentCorpus", propOrder = { "pair", "annotated" })
@XmlRootElement
public class EntailmentCorpus {
| // Path: edits-core/src/main/java/org/edits/EditsTextAnnotator.java
// public interface EditsTextAnnotator {
//
// public List<Annotation> annotate(String text) throws Exception;
//
// }
// Path: edits-core/src/main/java/org/edits/etaf/EntailmentCorpus.java
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import lombok.Data;
import org.edits.EditsTextAnnotator;
import com.google.common.collect.Lists;
package org.edits.etaf;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "EntailmentCorpus", propOrder = { "pair", "annotated" })
@XmlRootElement
public class EntailmentCorpus {
| public static List<AnnotatedEntailmentPair> annotate(EditsTextAnnotator annotator, List<EntailmentPair> paies) |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/weight/WordLength.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation; | package org.edits.distance.weight;
public class WordLength implements NamedWeightCalculator {
private static final long serialVersionUID = 1L;
public static final String WORD_LENGTH = "wordlength";
@Override
public WeightCalculator clone() {
return new WordLength();
}
@Override
public String name() {
return WORD_LENGTH;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/weight/WordLength.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
package org.edits.distance.weight;
public class WordLength implements NamedWeightCalculator {
private static final long serialVersionUID = 1L;
public static final String WORD_LENGTH = "wordlength";
@Override
public WeightCalculator clone() {
return new WordLength();
}
@Override
public String name() {
return WORD_LENGTH;
}
@Override | public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/weight/WordLength.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation; | package org.edits.distance.weight;
public class WordLength implements NamedWeightCalculator {
private static final long serialVersionUID = 1L;
public static final String WORD_LENGTH = "wordlength";
@Override
public WeightCalculator clone() {
return new WordLength();
}
@Override
public String name() {
return WORD_LENGTH;
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/weight/WordLength.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
package org.edits.distance.weight;
public class WordLength implements NamedWeightCalculator {
private static final long serialVersionUID = 1L;
public static final String WORD_LENGTH = "wordlength";
@Override
public WeightCalculator clone() {
return new WordLength();
}
@Override
public String name() {
return WORD_LENGTH;
}
@Override | public double weightH(Annotation node, AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-core/src/main/java/org/edits/engines/weka/features/DistanceFeature.java | // Path: edits-core/src/main/java/org/edits/distance/algorithm/EditDistanceAlgorithm.java
// @Data
// @Log4j
// public abstract class EditDistanceAlgorithm implements Serializable, Cloneable {
//
// private static final long serialVersionUID = 1L;
// private Matcher matcher;
// private boolean normalize;
//
// public EditDistanceAlgorithm() {
// normalize = true;
// matcher = new DefaultMatcher();
// }
//
// @Override
// public abstract EditDistanceAlgorithm clone();
//
// public EditDistanceAlgorithm defaultCopy() {
// EditDistanceAlgorithm a = instance(this.getClass().getName());
// a.setMatcher(getMatcher().copy());
// a.setNormalize(normalize);
// return a;
// }
//
// public double distance(AnnotatedText t, AnnotatedText h, String pairID) {
// List<Annotation> w1 = t.getAnnotation();
// List<Annotation> w2 = h.getAnnotation();
// return distance(w1, w2, t, h, pairID);
// }
//
// public abstract double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h,
// String pairID);
//
// public double init(double dist, double norm) {
// if (!normalize)
// return dist;
// return dist / norm;
// }
//
// public EditDistanceAlgorithm instance(String name) {
// try {
// return (EditDistanceAlgorithm) this.getClass().getClassLoader().loadClass(this.getClass().getName())
// .newInstance();
// } catch (Exception e) {
// log.debug(e);
// throw new RuntimeException("Could not load algorithm " + name);
// }
// }
// }
//
// Path: edits-core/src/main/java/org/edits/engines/OptimizationGoal.java
// @ToString(includeFieldNames = true)
// public class OptimizationGoal implements Serializable {
//
// public enum Target {
// ACCURACY, FMEASURE, PRECISION, RECALL
// }
//
// public static final OptimizationGoal ACCURACY = new OptimizationGoal(Target.ACCURACY, null);
//
// public static final OptimizationGoal FMEASURE_NO = new OptimizationGoal(Target.FMEASURE, "NO");
// public static final OptimizationGoal FMEASURE_YES = new OptimizationGoal(Target.FMEASURE, "YES");
// public static final OptimizationGoal PRECISION_NO = new OptimizationGoal(Target.PRECISION, "NO");
// public static final OptimizationGoal PRECISION_YES = new OptimizationGoal(Target.PRECISION, "YES");
// public static final OptimizationGoal RECALL_NO = new OptimizationGoal(Target.RECALL, "NO");
// public static final OptimizationGoal RECALL_YES = new OptimizationGoal(Target.RECALL, "YES");
//
// private static final long serialVersionUID = 1L;
//
// @Getter
// private final String relation;
// @Getter
// private final Target target;
//
// public OptimizationGoal() {
// this(Target.ACCURACY, null);
// }
//
// public OptimizationGoal(Target target, String relation) {
// super();
// this.relation = relation;
// this.target = target;
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
| import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.edits.distance.algorithm.EditDistanceAlgorithm;
import org.edits.engines.OptimizationGoal;
import org.edits.etaf.AnnotatedEntailmentPair;
import org.edits.etaf.AnnotatedText; | package org.edits.engines.weka.features;
@ToString
@EqualsAndHashCode(callSuper = false)
public class DistanceFeature extends Feature {
private static final long serialVersionUID = 1L;
@Getter | // Path: edits-core/src/main/java/org/edits/distance/algorithm/EditDistanceAlgorithm.java
// @Data
// @Log4j
// public abstract class EditDistanceAlgorithm implements Serializable, Cloneable {
//
// private static final long serialVersionUID = 1L;
// private Matcher matcher;
// private boolean normalize;
//
// public EditDistanceAlgorithm() {
// normalize = true;
// matcher = new DefaultMatcher();
// }
//
// @Override
// public abstract EditDistanceAlgorithm clone();
//
// public EditDistanceAlgorithm defaultCopy() {
// EditDistanceAlgorithm a = instance(this.getClass().getName());
// a.setMatcher(getMatcher().copy());
// a.setNormalize(normalize);
// return a;
// }
//
// public double distance(AnnotatedText t, AnnotatedText h, String pairID) {
// List<Annotation> w1 = t.getAnnotation();
// List<Annotation> w2 = h.getAnnotation();
// return distance(w1, w2, t, h, pairID);
// }
//
// public abstract double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h,
// String pairID);
//
// public double init(double dist, double norm) {
// if (!normalize)
// return dist;
// return dist / norm;
// }
//
// public EditDistanceAlgorithm instance(String name) {
// try {
// return (EditDistanceAlgorithm) this.getClass().getClassLoader().loadClass(this.getClass().getName())
// .newInstance();
// } catch (Exception e) {
// log.debug(e);
// throw new RuntimeException("Could not load algorithm " + name);
// }
// }
// }
//
// Path: edits-core/src/main/java/org/edits/engines/OptimizationGoal.java
// @ToString(includeFieldNames = true)
// public class OptimizationGoal implements Serializable {
//
// public enum Target {
// ACCURACY, FMEASURE, PRECISION, RECALL
// }
//
// public static final OptimizationGoal ACCURACY = new OptimizationGoal(Target.ACCURACY, null);
//
// public static final OptimizationGoal FMEASURE_NO = new OptimizationGoal(Target.FMEASURE, "NO");
// public static final OptimizationGoal FMEASURE_YES = new OptimizationGoal(Target.FMEASURE, "YES");
// public static final OptimizationGoal PRECISION_NO = new OptimizationGoal(Target.PRECISION, "NO");
// public static final OptimizationGoal PRECISION_YES = new OptimizationGoal(Target.PRECISION, "YES");
// public static final OptimizationGoal RECALL_NO = new OptimizationGoal(Target.RECALL, "NO");
// public static final OptimizationGoal RECALL_YES = new OptimizationGoal(Target.RECALL, "YES");
//
// private static final long serialVersionUID = 1L;
//
// @Getter
// private final String relation;
// @Getter
// private final Target target;
//
// public OptimizationGoal() {
// this(Target.ACCURACY, null);
// }
//
// public OptimizationGoal(Target target, String relation) {
// super();
// this.relation = relation;
// this.target = target;
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
// Path: edits-core/src/main/java/org/edits/engines/weka/features/DistanceFeature.java
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.edits.distance.algorithm.EditDistanceAlgorithm;
import org.edits.engines.OptimizationGoal;
import org.edits.etaf.AnnotatedEntailmentPair;
import org.edits.etaf.AnnotatedText;
package org.edits.engines.weka.features;
@ToString
@EqualsAndHashCode(callSuper = false)
public class DistanceFeature extends Feature {
private static final long serialVersionUID = 1L;
@Getter | private EditDistanceAlgorithm algorithm; |
kouylekov/edits | edits-core/src/main/java/org/edits/engines/weka/features/DistanceFeature.java | // Path: edits-core/src/main/java/org/edits/distance/algorithm/EditDistanceAlgorithm.java
// @Data
// @Log4j
// public abstract class EditDistanceAlgorithm implements Serializable, Cloneable {
//
// private static final long serialVersionUID = 1L;
// private Matcher matcher;
// private boolean normalize;
//
// public EditDistanceAlgorithm() {
// normalize = true;
// matcher = new DefaultMatcher();
// }
//
// @Override
// public abstract EditDistanceAlgorithm clone();
//
// public EditDistanceAlgorithm defaultCopy() {
// EditDistanceAlgorithm a = instance(this.getClass().getName());
// a.setMatcher(getMatcher().copy());
// a.setNormalize(normalize);
// return a;
// }
//
// public double distance(AnnotatedText t, AnnotatedText h, String pairID) {
// List<Annotation> w1 = t.getAnnotation();
// List<Annotation> w2 = h.getAnnotation();
// return distance(w1, w2, t, h, pairID);
// }
//
// public abstract double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h,
// String pairID);
//
// public double init(double dist, double norm) {
// if (!normalize)
// return dist;
// return dist / norm;
// }
//
// public EditDistanceAlgorithm instance(String name) {
// try {
// return (EditDistanceAlgorithm) this.getClass().getClassLoader().loadClass(this.getClass().getName())
// .newInstance();
// } catch (Exception e) {
// log.debug(e);
// throw new RuntimeException("Could not load algorithm " + name);
// }
// }
// }
//
// Path: edits-core/src/main/java/org/edits/engines/OptimizationGoal.java
// @ToString(includeFieldNames = true)
// public class OptimizationGoal implements Serializable {
//
// public enum Target {
// ACCURACY, FMEASURE, PRECISION, RECALL
// }
//
// public static final OptimizationGoal ACCURACY = new OptimizationGoal(Target.ACCURACY, null);
//
// public static final OptimizationGoal FMEASURE_NO = new OptimizationGoal(Target.FMEASURE, "NO");
// public static final OptimizationGoal FMEASURE_YES = new OptimizationGoal(Target.FMEASURE, "YES");
// public static final OptimizationGoal PRECISION_NO = new OptimizationGoal(Target.PRECISION, "NO");
// public static final OptimizationGoal PRECISION_YES = new OptimizationGoal(Target.PRECISION, "YES");
// public static final OptimizationGoal RECALL_NO = new OptimizationGoal(Target.RECALL, "NO");
// public static final OptimizationGoal RECALL_YES = new OptimizationGoal(Target.RECALL, "YES");
//
// private static final long serialVersionUID = 1L;
//
// @Getter
// private final String relation;
// @Getter
// private final Target target;
//
// public OptimizationGoal() {
// this(Target.ACCURACY, null);
// }
//
// public OptimizationGoal(Target target, String relation) {
// super();
// this.relation = relation;
// this.target = target;
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
| import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.edits.distance.algorithm.EditDistanceAlgorithm;
import org.edits.engines.OptimizationGoal;
import org.edits.etaf.AnnotatedEntailmentPair;
import org.edits.etaf.AnnotatedText; | package org.edits.engines.weka.features;
@ToString
@EqualsAndHashCode(callSuper = false)
public class DistanceFeature extends Feature {
private static final long serialVersionUID = 1L;
@Getter
private EditDistanceAlgorithm algorithm;
private String name;
@Getter
@Setter
private boolean reverseDistance;
public DistanceFeature(EditDistanceAlgorithm algorithm2) {
reverseDistance = false;
algorithm = algorithm2;
name = algorithm.getClass().getName();
}
@Override
public Feature clone() {
return new DistanceFeature(algorithm.clone());
}
@Override | // Path: edits-core/src/main/java/org/edits/distance/algorithm/EditDistanceAlgorithm.java
// @Data
// @Log4j
// public abstract class EditDistanceAlgorithm implements Serializable, Cloneable {
//
// private static final long serialVersionUID = 1L;
// private Matcher matcher;
// private boolean normalize;
//
// public EditDistanceAlgorithm() {
// normalize = true;
// matcher = new DefaultMatcher();
// }
//
// @Override
// public abstract EditDistanceAlgorithm clone();
//
// public EditDistanceAlgorithm defaultCopy() {
// EditDistanceAlgorithm a = instance(this.getClass().getName());
// a.setMatcher(getMatcher().copy());
// a.setNormalize(normalize);
// return a;
// }
//
// public double distance(AnnotatedText t, AnnotatedText h, String pairID) {
// List<Annotation> w1 = t.getAnnotation();
// List<Annotation> w2 = h.getAnnotation();
// return distance(w1, w2, t, h, pairID);
// }
//
// public abstract double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h,
// String pairID);
//
// public double init(double dist, double norm) {
// if (!normalize)
// return dist;
// return dist / norm;
// }
//
// public EditDistanceAlgorithm instance(String name) {
// try {
// return (EditDistanceAlgorithm) this.getClass().getClassLoader().loadClass(this.getClass().getName())
// .newInstance();
// } catch (Exception e) {
// log.debug(e);
// throw new RuntimeException("Could not load algorithm " + name);
// }
// }
// }
//
// Path: edits-core/src/main/java/org/edits/engines/OptimizationGoal.java
// @ToString(includeFieldNames = true)
// public class OptimizationGoal implements Serializable {
//
// public enum Target {
// ACCURACY, FMEASURE, PRECISION, RECALL
// }
//
// public static final OptimizationGoal ACCURACY = new OptimizationGoal(Target.ACCURACY, null);
//
// public static final OptimizationGoal FMEASURE_NO = new OptimizationGoal(Target.FMEASURE, "NO");
// public static final OptimizationGoal FMEASURE_YES = new OptimizationGoal(Target.FMEASURE, "YES");
// public static final OptimizationGoal PRECISION_NO = new OptimizationGoal(Target.PRECISION, "NO");
// public static final OptimizationGoal PRECISION_YES = new OptimizationGoal(Target.PRECISION, "YES");
// public static final OptimizationGoal RECALL_NO = new OptimizationGoal(Target.RECALL, "NO");
// public static final OptimizationGoal RECALL_YES = new OptimizationGoal(Target.RECALL, "YES");
//
// private static final long serialVersionUID = 1L;
//
// @Getter
// private final String relation;
// @Getter
// private final Target target;
//
// public OptimizationGoal() {
// this(Target.ACCURACY, null);
// }
//
// public OptimizationGoal(Target target, String relation) {
// super();
// this.relation = relation;
// this.target = target;
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
// Path: edits-core/src/main/java/org/edits/engines/weka/features/DistanceFeature.java
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.edits.distance.algorithm.EditDistanceAlgorithm;
import org.edits.engines.OptimizationGoal;
import org.edits.etaf.AnnotatedEntailmentPair;
import org.edits.etaf.AnnotatedText;
package org.edits.engines.weka.features;
@ToString
@EqualsAndHashCode(callSuper = false)
public class DistanceFeature extends Feature {
private static final long serialVersionUID = 1L;
@Getter
private EditDistanceAlgorithm algorithm;
private String name;
@Getter
@Setter
private boolean reverseDistance;
public DistanceFeature(EditDistanceAlgorithm algorithm2) {
reverseDistance = false;
algorithm = algorithm2;
name = algorithm.getClass().getName();
}
@Override
public Feature clone() {
return new DistanceFeature(algorithm.clone());
}
@Override | public double doubleValue(AnnotatedEntailmentPair pair) { |
kouylekov/edits | edits-core/src/main/java/org/edits/rules/AnnotationRule.java | // Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import lombok.Data;
import org.edits.etaf.Annotation; | package org.edits.rules;
@Data
public class AnnotationRule implements Rule {
| // Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/rules/AnnotationRule.java
import lombok.Data;
import org.edits.etaf.Annotation;
package org.edits.rules;
@Data
public class AnnotationRule implements Rule {
| private Annotation h; |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/LCS.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import java.util.List; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class LCS extends EditDistanceAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/LCS.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import java.util.List;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class LCS extends EditDistanceAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | public double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/LCS.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import java.util.List; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class LCS extends EditDistanceAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/LCS.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import java.util.List;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class LCS extends EditDistanceAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | public double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/TokenEditDistance.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import java.util.List; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class TokenEditDistance extends WeightedAlgorithm {
private static final long serialVersionUID = 1L;
private static double minimum(double a, double b, double c) {
double mi = a < b ? a : b;
return c < mi ? c : mi;
}
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
| // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/TokenEditDistance.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import java.util.List;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class TokenEditDistance extends WeightedAlgorithm {
private static final long serialVersionUID = 1L;
private static double minimum(double a, double b, double c) {
double mi = a < b ? a : b;
return c < mi ? c : mi;
}
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
| private double delete(Annotation node, AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/TokenEditDistance.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import java.util.List; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class TokenEditDistance extends WeightedAlgorithm {
private static final long serialVersionUID = 1L;
private static double minimum(double a, double b, double c) {
double mi = a < b ? a : b;
return c < mi ? c : mi;
}
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
| // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/TokenEditDistance.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import java.util.List;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class TokenEditDistance extends WeightedAlgorithm {
private static final long serialVersionUID = 1L;
private static double minimum(double a, double b, double c) {
double mi = a < b ? a : b;
return c < mi ? c : mi;
}
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
| private double delete(Annotation node, AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-core/src/main/java/org/edits/engines/EntailmentEngine.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
| import java.util.List;
import lombok.Data;
import org.edits.etaf.AnnotatedEntailmentPair;
import java.io.Serializable; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.engines;
/**
*
* @author Milen Kouylekov
*
*/
@Data
public abstract class EntailmentEngine implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private OptimizationGoal goal;
| // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
// Path: edits-core/src/main/java/org/edits/engines/EntailmentEngine.java
import java.util.List;
import lombok.Data;
import org.edits.etaf.AnnotatedEntailmentPair;
import java.io.Serializable;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.engines;
/**
*
* @author Milen Kouylekov
*
*/
@Data
public abstract class EntailmentEngine implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private OptimizationGoal goal;
| public abstract EvaluationResult evaluate(AnnotatedEntailmentPair p); |
kouylekov/edits | edits-core/src/main/java/org/edits/rules/IndexRulesSource.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Set;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.log4j.Log4j;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.FSDirectory;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets; | package org.edits.rules;
@Log4j
@Data
@EqualsAndHashCode(callSuper = false)
public class IndexRulesSource extends RulesSource {
private static Map<String, IndexSearcher> searchers;
private static final long serialVersionUID = 1L;
public static final String TERMDOC_FIELD = "value";
public static final String USES_FIELD = "uses";
public static final String VALUE_FIELD = "termsDoc";
static {
searchers = Maps.newHashMap();
}
| // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/rules/IndexRulesSource.java
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Set;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.log4j.Log4j;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.FSDirectory;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
package org.edits.rules;
@Log4j
@Data
@EqualsAndHashCode(callSuper = false)
public class IndexRulesSource extends RulesSource {
private static Map<String, IndexSearcher> searchers;
private static final long serialVersionUID = 1L;
public static final String TERMDOC_FIELD = "value";
public static final String USES_FIELD = "uses";
public static final String VALUE_FIELD = "termsDoc";
static {
searchers = Maps.newHashMap();
}
| public static String value(String f, Annotation a1) { |
kouylekov/edits | edits-core/src/main/java/org/edits/rules/IndexRulesSource.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Set;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.log4j.Log4j;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.FSDirectory;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets; | Query q = new TermQuery(new Term(TERMDOC_FIELD, "true"));
TopDocs td = searcher().search(q, 1);
Document doc = searcher().doc(td.scoreDocs[0].doc);
for (String d : doc.getValues(USES_FIELD))
fields.add(d);
} catch (Exception e) {
log.debug(e);
throw new RuntimeException("Could not load index from " + indexPath);
}
}
@Override
public RulesSource clone() {
IndexRulesSource rs = new IndexRulesSource();
rs.setFields(fields);
rs.setIndexPath(indexPath);
return rs;
}
@Override
public void close() {
try {
searcher().getIndexReader().close();
} catch (Exception e) {
log.debug(e);
throw new RuntimeException(e);
}
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/rules/IndexRulesSource.java
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Set;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.log4j.Log4j;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.FSDirectory;
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
Query q = new TermQuery(new Term(TERMDOC_FIELD, "true"));
TopDocs td = searcher().search(q, 1);
Document doc = searcher().doc(td.scoreDocs[0].doc);
for (String d : doc.getValues(USES_FIELD))
fields.add(d);
} catch (Exception e) {
log.debug(e);
throw new RuntimeException("Could not load index from " + indexPath);
}
}
@Override
public RulesSource clone() {
IndexRulesSource rs = new IndexRulesSource();
rs.setFields(fields);
rs.setIndexPath(indexPath);
return rs;
}
@Override
public void close() {
try {
searcher().getIndexReader().close();
} catch (Exception e) {
log.debug(e);
throw new RuntimeException(e);
}
}
@Override | public List<Rule> extractRules(AnnotatedText t, AnnotatedText h) { |
kouylekov/edits | edits-server/src/main/java/org/edits/rest/RestService.java | // Path: edits-core/src/main/java/org/edits/engines/EvaluationResult.java
// @Data
// @XmlRootElement(name = "result")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class EvaluationResult implements Comparator<EvaluationResult>, Serializable {
//
// private static final long serialVersionUID = 1L;
// @XmlElement
// private String assigned;
// @XmlElement
// private String benchmark;
// @XmlElement
// private double confidence;
// @XmlElement
// private String id;
// @XmlElement
// private double score;
//
// public EvaluationResult() {
//
// }
//
// public EvaluationResult(String id, String assigned, String benchmark, double score, double confidence) {
//
// this.id = id;
// this.assigned = assigned;
// this.benchmark = benchmark;
// this.score = score;
// this.confidence = confidence;
// }
//
// @Override
// public int compare(EvaluationResult o1, EvaluationResult o2) {
// return o1.getId().compareTo(o2.getId());
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import lombok.Getter;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import org.apache.log4j.LogManager;
import org.edits.engines.EvaluationResult;
import org.edits.etaf.AnnotatedEntailmentPair;
import com.sun.jersey.api.container.httpserver.HttpServerFactory;
import com.sun.jersey.api.core.DefaultResourceConfig; |
public static void test() throws ClientProtocolException, IOException {
HttpClient client = HttpClients.createDefault();
HttpGet request = new HttpGet("http://localhost:8095/system/evaluate?engine=rte7&t=b&h=b");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
rd.close();
request = new HttpGet("http://localhost:8095/system/evaluate?engine=rte7&t=a&h=b");
response = client.execute(request);
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
rd.close();
System.exit(0);
}
@Path("evaluate")
@Produces(MediaType.APPLICATION_JSON)
@GET
public Response evaluate(@DefaultValue(EngineManager.DEFAULT_ENTAILMENT_ENGINE) @QueryParam("engine") String id,
@QueryParam("t") String t, @QueryParam("h") String h) {
try {
init();
EngineInstance e = manager.get(id); | // Path: edits-core/src/main/java/org/edits/engines/EvaluationResult.java
// @Data
// @XmlRootElement(name = "result")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class EvaluationResult implements Comparator<EvaluationResult>, Serializable {
//
// private static final long serialVersionUID = 1L;
// @XmlElement
// private String assigned;
// @XmlElement
// private String benchmark;
// @XmlElement
// private double confidence;
// @XmlElement
// private String id;
// @XmlElement
// private double score;
//
// public EvaluationResult() {
//
// }
//
// public EvaluationResult(String id, String assigned, String benchmark, double score, double confidence) {
//
// this.id = id;
// this.assigned = assigned;
// this.benchmark = benchmark;
// this.score = score;
// this.confidence = confidence;
// }
//
// @Override
// public int compare(EvaluationResult o1, EvaluationResult o2) {
// return o1.getId().compareTo(o2.getId());
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
// Path: edits-server/src/main/java/org/edits/rest/RestService.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import lombok.Getter;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import org.apache.log4j.LogManager;
import org.edits.engines.EvaluationResult;
import org.edits.etaf.AnnotatedEntailmentPair;
import com.sun.jersey.api.container.httpserver.HttpServerFactory;
import com.sun.jersey.api.core.DefaultResourceConfig;
public static void test() throws ClientProtocolException, IOException {
HttpClient client = HttpClients.createDefault();
HttpGet request = new HttpGet("http://localhost:8095/system/evaluate?engine=rte7&t=b&h=b");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
rd.close();
request = new HttpGet("http://localhost:8095/system/evaluate?engine=rte7&t=a&h=b");
response = client.execute(request);
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
rd.close();
System.exit(0);
}
@Path("evaluate")
@Produces(MediaType.APPLICATION_JSON)
@GET
public Response evaluate(@DefaultValue(EngineManager.DEFAULT_ENTAILMENT_ENGINE) @QueryParam("engine") String id,
@QueryParam("t") String t, @QueryParam("h") String h) {
try {
init();
EngineInstance e = manager.get(id); | AnnotatedEntailmentPair p = AnnotatedEntailmentPair.create(t, h, e.annotator()); |
kouylekov/edits | edits-server/src/main/java/org/edits/rest/RestService.java | // Path: edits-core/src/main/java/org/edits/engines/EvaluationResult.java
// @Data
// @XmlRootElement(name = "result")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class EvaluationResult implements Comparator<EvaluationResult>, Serializable {
//
// private static final long serialVersionUID = 1L;
// @XmlElement
// private String assigned;
// @XmlElement
// private String benchmark;
// @XmlElement
// private double confidence;
// @XmlElement
// private String id;
// @XmlElement
// private double score;
//
// public EvaluationResult() {
//
// }
//
// public EvaluationResult(String id, String assigned, String benchmark, double score, double confidence) {
//
// this.id = id;
// this.assigned = assigned;
// this.benchmark = benchmark;
// this.score = score;
// this.confidence = confidence;
// }
//
// @Override
// public int compare(EvaluationResult o1, EvaluationResult o2) {
// return o1.getId().compareTo(o2.getId());
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import lombok.Getter;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import org.apache.log4j.LogManager;
import org.edits.engines.EvaluationResult;
import org.edits.etaf.AnnotatedEntailmentPair;
import com.sun.jersey.api.container.httpserver.HttpServerFactory;
import com.sun.jersey.api.core.DefaultResourceConfig; | HttpClient client = HttpClients.createDefault();
HttpGet request = new HttpGet("http://localhost:8095/system/evaluate?engine=rte7&t=b&h=b");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
rd.close();
request = new HttpGet("http://localhost:8095/system/evaluate?engine=rte7&t=a&h=b");
response = client.execute(request);
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
rd.close();
System.exit(0);
}
@Path("evaluate")
@Produces(MediaType.APPLICATION_JSON)
@GET
public Response evaluate(@DefaultValue(EngineManager.DEFAULT_ENTAILMENT_ENGINE) @QueryParam("engine") String id,
@QueryParam("t") String t, @QueryParam("h") String h) {
try {
init();
EngineInstance e = manager.get(id);
AnnotatedEntailmentPair p = AnnotatedEntailmentPair.create(t, h, e.annotator());
System.out.println(p); | // Path: edits-core/src/main/java/org/edits/engines/EvaluationResult.java
// @Data
// @XmlRootElement(name = "result")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class EvaluationResult implements Comparator<EvaluationResult>, Serializable {
//
// private static final long serialVersionUID = 1L;
// @XmlElement
// private String assigned;
// @XmlElement
// private String benchmark;
// @XmlElement
// private double confidence;
// @XmlElement
// private String id;
// @XmlElement
// private double score;
//
// public EvaluationResult() {
//
// }
//
// public EvaluationResult(String id, String assigned, String benchmark, double score, double confidence) {
//
// this.id = id;
// this.assigned = assigned;
// this.benchmark = benchmark;
// this.score = score;
// this.confidence = confidence;
// }
//
// @Override
// public int compare(EvaluationResult o1, EvaluationResult o2) {
// return o1.getId().compareTo(o2.getId());
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/AnnotatedEntailmentPair.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedEntailmentPair", propOrder = { "t", "h" })
// public class AnnotatedEntailmentPair {
//
// public static AnnotatedEntailmentPair create(String t2, String h2, EditsTextAnnotator annotator) throws Exception {
// AnnotatedEntailmentPair px = new AnnotatedEntailmentPair();
// AnnotatedText at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(t2));
// px.getT().add(at);
// at = new AnnotatedText();
// at.getAnnotation().addAll(annotator.annotate(h2));
// px.getH().add(at);
// return px;
// }
//
// @XmlTransient
// private Map<String, String> attributes;
// @XmlAttribute
// protected String entailment;
// @XmlElement
// protected List<AnnotatedText> h;
// @XmlAttribute
// protected String id;
//
// @XmlTransient
// private int order;
//
// @XmlElement
// protected List<AnnotatedText> t;
//
// @XmlAttribute
// protected String task;
//
// public AnnotatedEntailmentPair() {
// t = Lists.newArrayList();
// h = Lists.newArrayList();
// attributes = Maps.newHashMap();
// }
//
// }
// Path: edits-server/src/main/java/org/edits/rest/RestService.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import lombok.Getter;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import org.apache.log4j.LogManager;
import org.edits.engines.EvaluationResult;
import org.edits.etaf.AnnotatedEntailmentPair;
import com.sun.jersey.api.container.httpserver.HttpServerFactory;
import com.sun.jersey.api.core.DefaultResourceConfig;
HttpClient client = HttpClients.createDefault();
HttpGet request = new HttpGet("http://localhost:8095/system/evaluate?engine=rte7&t=b&h=b");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
rd.close();
request = new HttpGet("http://localhost:8095/system/evaluate?engine=rte7&t=a&h=b");
response = client.execute(request);
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
rd.close();
System.exit(0);
}
@Path("evaluate")
@Produces(MediaType.APPLICATION_JSON)
@GET
public Response evaluate(@DefaultValue(EngineManager.DEFAULT_ENTAILMENT_ENGINE) @QueryParam("engine") String id,
@QueryParam("t") String t, @QueryParam("h") String h) {
try {
init();
EngineInstance e = manager.get(id);
AnnotatedEntailmentPair p = AnnotatedEntailmentPair.create(t, h, e.annotator());
System.out.println(p); | EvaluationResult r = e.getModel().getEngine().evaluate(p); |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/JaccardCoefficient.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import java.util.List; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class JaccardCoefficient extends EditDistanceAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/JaccardCoefficient.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import java.util.List;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class JaccardCoefficient extends EditDistanceAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | public double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-core/src/main/java/org/edits/distance/algorithm/JaccardCoefficient.java | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import java.util.List; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class JaccardCoefficient extends EditDistanceAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | // Path: edits-core/src/main/java/org/edits/etaf/AnnotatedText.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "AnnotatedText", propOrder = { "annotation" })
// public class AnnotatedText {
//
// @XmlElement
// protected List<Annotation> annotation;
//
// public AnnotatedText() {
// annotation = Lists.newArrayList();
// }
// }
//
// Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/distance/algorithm/JaccardCoefficient.java
import org.edits.etaf.AnnotatedText;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import java.util.List;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits.distance.algorithm;
/**
* @author Milen Kouylekov
*/
public class JaccardCoefficient extends EditDistanceAlgorithm {
private static final long serialVersionUID = 1L;
@Override
public EditDistanceAlgorithm clone() {
return defaultCopy();
}
@Override | public double distance(List<Annotation> ta, List<Annotation> ha, AnnotatedText t, AnnotatedText h, String pairID) { |
kouylekov/edits | edits-core/src/main/java/org/edits/LuceneTokenizer.java | // Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import java.io.StringReader;
import java.util.List;
import lombok.extern.log4j.Log4j;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.analysis.en.EnglishAnalyzer;
import org.apache.lucene.analysis.en.EnglishMinimalStemFilter;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.util.CharArraySet;
import org.apache.lucene.util.Version;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits;
/**
* @author Milen Kouylekov
*/
@Log4j
public class LuceneTokenizer implements EditsTextAnnotator {
@Override | // Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/LuceneTokenizer.java
import java.io.StringReader;
import java.util.List;
import lombok.extern.log4j.Log4j;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.analysis.en.EnglishAnalyzer;
import org.apache.lucene.analysis.en.EnglishMinimalStemFilter;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.util.CharArraySet;
import org.apache.lucene.util.Version;
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits;
/**
* @author Milen Kouylekov
*/
@Log4j
public class LuceneTokenizer implements EditsTextAnnotator {
@Override | public List<Annotation> annotate(String text) throws Exception { |
kouylekov/edits | edits-core/src/main/java/org/edits/SimpleTokenizer.java | // Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
| import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import java.util.List; | /**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits;
/**
* @author Milen Kouylekov
*/
public class SimpleTokenizer implements EditsTextAnnotator {
public static String format(String text) {
text = text.replace("\t", " ");
text = text.replace("\n", " ");
text = text.replace("\r", " ");
String old = text;
text = text.replace(" ", " ");
while (old.length() > text.length()) {
old = text;
text = text.replace(" ", " ");
}
return text;
}
| // Path: edits-core/src/main/java/org/edits/etaf/Annotation.java
// @Data
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "Annotation", propOrder = {})
// @XmlRootElement(name = "annotation")
// public class Annotation {
//
// @XmlAttribute
// private String cpostag;
// @XmlAttribute
// private String deprel;
// @XmlAttribute
// private int end;
// @XmlAttribute
// private String feats;
// @XmlAttribute
// private String form;
// @XmlAttribute
// private String head;
// @XmlAttribute
// private String id;
// @XmlAttribute
// private String lemma;
// @XmlAttribute
// private String postag;
// @XmlAttribute
// private int start;
//
// }
// Path: edits-core/src/main/java/org/edits/SimpleTokenizer.java
import org.edits.etaf.Annotation;
import com.google.common.collect.Lists;
import java.util.List;
/**
* Edits - Edit Distance Textual Entailment Suite Copyright (C) 2011 Milen
* Kouylekov This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version. This library is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details. You should have
* received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.edits;
/**
* @author Milen Kouylekov
*/
public class SimpleTokenizer implements EditsTextAnnotator {
public static String format(String text) {
text = text.replace("\t", " ");
text = text.replace("\n", " ");
text = text.replace("\r", " ");
String old = text;
text = text.replace(" ", " ");
while (old.length() > text.length()) {
old = text;
text = text.replace(" ", " ");
}
return text;
}
| public List<Annotation> annotate(String text) { |
tastybento/askygrid | src/com/wasteofplastic/askygrid/generators/SkyGridGen.java | // Path: src/com/wasteofplastic/askygrid/Settings.java
// public class Settings {
// // Permission prefix
// public final static String PERMPREFIX = "askygrid.";
// // The island command
// public final static String ISLANDCOMMAND = "asg";
// // The challenge command
// public static final String CHALLENGECOMMAND = "asgc";
// // The spawn command (Essentials spawn for example)
// public final static String SPAWNCOMMAND = "spawn";
// // Admin command
// public static final String ADMINCOMMAND = "asgadmin";
//
// public static Set<String> challengeList;
// public static int waiverAmount;
// public static List<String> challengeLevels;
// public static String worldName;
// public static int monsterSpawnLimit;
// public static int animalSpawnLimit;
// public static int waterAnimalSpawnLimit;
// // IslandGuard settings
// public static boolean allowPvP;
// public static int spawnDistance;
// public static int islandXOffset;
// public static int islandZOffset;
// public static int claim_protectionRange;
// public static Double startingMoney;
// public static boolean resetMoney;
//
// // public static boolean ultraSafeBoats;
// public static boolean logInRemoveMobs;
// public static boolean removeMobs;
//
// // Challenge completion broadcast
// public static boolean broadcastMessages;
// // Nether world
// public static boolean createNether;
// public static boolean clearInventory;
// // Use control panel for /island
// public static boolean useControlPanel;
// // Prevent /island when falling
// public static boolean allowTeleportWhenFalling;
// // Challenges - show or remove completed on-time challenges
// public static boolean removeCompleteOntimeChallenges;
// public static boolean addCompletedGlow;
//
// // Use Economy
// public static boolean useEconomy;
//
// // Use physics when pasting schematic blocks
// public static boolean usePhysics;
//
// // Falling blocked commands
// public static List<String> fallingCommandBlockList;
// public static boolean resetEnderChest;
// public static boolean updateCheck;
// public static long islandStartX;
// public static long islandStartZ;
// public static boolean allowNetherPvP;
// public static int maxHomes;
// public static boolean immediateTeleport;
// public static int debug;
// public static boolean respawnAtHome;
// public static boolean restrictWither;
// public static List<String> startCommands;
// public static boolean useWarpPanel;
// public static List<EntityType> mobWhiteList = new ArrayList<EntityType>();
// public static boolean muteDeathMessages;
// public static boolean allowFireSpread;
// public static int gridHeight;
// public static boolean allowBreakBlocks;
// public static boolean allowPlaceBlocks;
// public static boolean allowBedUse;
// public static boolean allowBucketUse;
// public static boolean allowShearing;
// public static boolean allowEnderPearls;
// public static boolean allowDoorUse;
// public static boolean allowLeverButtonUse;
// public static boolean allowCropTrample;
// public static boolean allowChestAccess;
// public static boolean allowFurnaceUse;
// public static boolean allowRedStone;
// public static boolean allowMusic;
// public static boolean allowCrafting;
// public static boolean allowBrewing;
// public static boolean allowGateUse;
// public static boolean allowMobHarm;
// public static boolean allowFlowIn;
// public static boolean allowFlowOut;
// public static int spawnHeight;
// public static boolean allowTNTDamage;
// public static boolean allowChestDamage;
// public static List<String> bannedCommandList;
//
//
// public static boolean allowHorseInvAccess;
// public static boolean createEnd;
// public static double endPortalProb;
// public static long spawnCenterX;
// public static long spawnCenterZ;
// public static boolean allowFallDamage;
// public static boolean createBiomes;
// public static boolean growTrees;
// public static Sound warpSound;
// }
| import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import com.wasteofplastic.askygrid.Settings; | package com.wasteofplastic.askygrid.generators;
public class SkyGridGen extends ChunkGenerator {
// Blocks that need to be placed on dirt
private final static List<Material> needDirt = Arrays.asList(Material.SAPLING, Material.RED_MUSHROOM, Material.BROWN_MUSHROOM,
Material.SUGAR_CANE_BLOCK, Material.LONG_GRASS, Material.DEAD_BUSH, Material.YELLOW_FLOWER, Material.RED_ROSE, Material.DOUBLE_PLANT);
@Override
public byte[][] generateBlockSections(World world, Random random, int chunkx, int chunkz, BiomeGrid biomeGrid) {
BiomeGenerator biomeGenerator = new BiomeGenerator(world);
// Default block
Material blockMat = Material.AIR;
// This gets all the blocks that can be picked and their probabilities
BlockProbability prob = WorldStyles.get(world.getEnvironment()).getProb();
// Biomes
// Settings.createBiomes
//int noise = (int)Math.floor(voronoi.noise(chunkx, chunkz, 1) * Biome.values().length);
//Bukkit.getLogger().info("DEBUG: " + noise + " biome = " + Biome.values()[noise]);
// The chunk we are making
byte[][] chunk = new byte[world.getMaxHeight() / 16][]; | // Path: src/com/wasteofplastic/askygrid/Settings.java
// public class Settings {
// // Permission prefix
// public final static String PERMPREFIX = "askygrid.";
// // The island command
// public final static String ISLANDCOMMAND = "asg";
// // The challenge command
// public static final String CHALLENGECOMMAND = "asgc";
// // The spawn command (Essentials spawn for example)
// public final static String SPAWNCOMMAND = "spawn";
// // Admin command
// public static final String ADMINCOMMAND = "asgadmin";
//
// public static Set<String> challengeList;
// public static int waiverAmount;
// public static List<String> challengeLevels;
// public static String worldName;
// public static int monsterSpawnLimit;
// public static int animalSpawnLimit;
// public static int waterAnimalSpawnLimit;
// // IslandGuard settings
// public static boolean allowPvP;
// public static int spawnDistance;
// public static int islandXOffset;
// public static int islandZOffset;
// public static int claim_protectionRange;
// public static Double startingMoney;
// public static boolean resetMoney;
//
// // public static boolean ultraSafeBoats;
// public static boolean logInRemoveMobs;
// public static boolean removeMobs;
//
// // Challenge completion broadcast
// public static boolean broadcastMessages;
// // Nether world
// public static boolean createNether;
// public static boolean clearInventory;
// // Use control panel for /island
// public static boolean useControlPanel;
// // Prevent /island when falling
// public static boolean allowTeleportWhenFalling;
// // Challenges - show or remove completed on-time challenges
// public static boolean removeCompleteOntimeChallenges;
// public static boolean addCompletedGlow;
//
// // Use Economy
// public static boolean useEconomy;
//
// // Use physics when pasting schematic blocks
// public static boolean usePhysics;
//
// // Falling blocked commands
// public static List<String> fallingCommandBlockList;
// public static boolean resetEnderChest;
// public static boolean updateCheck;
// public static long islandStartX;
// public static long islandStartZ;
// public static boolean allowNetherPvP;
// public static int maxHomes;
// public static boolean immediateTeleport;
// public static int debug;
// public static boolean respawnAtHome;
// public static boolean restrictWither;
// public static List<String> startCommands;
// public static boolean useWarpPanel;
// public static List<EntityType> mobWhiteList = new ArrayList<EntityType>();
// public static boolean muteDeathMessages;
// public static boolean allowFireSpread;
// public static int gridHeight;
// public static boolean allowBreakBlocks;
// public static boolean allowPlaceBlocks;
// public static boolean allowBedUse;
// public static boolean allowBucketUse;
// public static boolean allowShearing;
// public static boolean allowEnderPearls;
// public static boolean allowDoorUse;
// public static boolean allowLeverButtonUse;
// public static boolean allowCropTrample;
// public static boolean allowChestAccess;
// public static boolean allowFurnaceUse;
// public static boolean allowRedStone;
// public static boolean allowMusic;
// public static boolean allowCrafting;
// public static boolean allowBrewing;
// public static boolean allowGateUse;
// public static boolean allowMobHarm;
// public static boolean allowFlowIn;
// public static boolean allowFlowOut;
// public static int spawnHeight;
// public static boolean allowTNTDamage;
// public static boolean allowChestDamage;
// public static List<String> bannedCommandList;
//
//
// public static boolean allowHorseInvAccess;
// public static boolean createEnd;
// public static double endPortalProb;
// public static long spawnCenterX;
// public static long spawnCenterZ;
// public static boolean allowFallDamage;
// public static boolean createBiomes;
// public static boolean growTrees;
// public static Sound warpSound;
// }
// Path: src/com/wasteofplastic/askygrid/generators/SkyGridGen.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import com.wasteofplastic.askygrid.Settings;
package com.wasteofplastic.askygrid.generators;
public class SkyGridGen extends ChunkGenerator {
// Blocks that need to be placed on dirt
private final static List<Material> needDirt = Arrays.asList(Material.SAPLING, Material.RED_MUSHROOM, Material.BROWN_MUSHROOM,
Material.SUGAR_CANE_BLOCK, Material.LONG_GRASS, Material.DEAD_BUSH, Material.YELLOW_FLOWER, Material.RED_ROSE, Material.DOUBLE_PLANT);
@Override
public byte[][] generateBlockSections(World world, Random random, int chunkx, int chunkz, BiomeGrid biomeGrid) {
BiomeGenerator biomeGenerator = new BiomeGenerator(world);
// Default block
Material blockMat = Material.AIR;
// This gets all the blocks that can be picked and their probabilities
BlockProbability prob = WorldStyles.get(world.getEnvironment()).getProb();
// Biomes
// Settings.createBiomes
//int noise = (int)Math.floor(voronoi.noise(chunkx, chunkz, 1) * Biome.values().length);
//Bukkit.getLogger().info("DEBUG: " + noise + " biome = " + Biome.values()[noise]);
// The chunk we are making
byte[][] chunk = new byte[world.getMaxHeight() / 16][]; | if (Settings.createBiomes && world.getEnvironment().equals(Environment.NORMAL)) { |
tastybento/askygrid | src/com/wasteofplastic/askygrid/generators/SkyGridPop.java | // Path: src/com/wasteofplastic/askygrid/Settings.java
// public class Settings {
// // Permission prefix
// public final static String PERMPREFIX = "askygrid.";
// // The island command
// public final static String ISLANDCOMMAND = "asg";
// // The challenge command
// public static final String CHALLENGECOMMAND = "asgc";
// // The spawn command (Essentials spawn for example)
// public final static String SPAWNCOMMAND = "spawn";
// // Admin command
// public static final String ADMINCOMMAND = "asgadmin";
//
// public static Set<String> challengeList;
// public static int waiverAmount;
// public static List<String> challengeLevels;
// public static String worldName;
// public static int monsterSpawnLimit;
// public static int animalSpawnLimit;
// public static int waterAnimalSpawnLimit;
// // IslandGuard settings
// public static boolean allowPvP;
// public static int spawnDistance;
// public static int islandXOffset;
// public static int islandZOffset;
// public static int claim_protectionRange;
// public static Double startingMoney;
// public static boolean resetMoney;
//
// // public static boolean ultraSafeBoats;
// public static boolean logInRemoveMobs;
// public static boolean removeMobs;
//
// // Challenge completion broadcast
// public static boolean broadcastMessages;
// // Nether world
// public static boolean createNether;
// public static boolean clearInventory;
// // Use control panel for /island
// public static boolean useControlPanel;
// // Prevent /island when falling
// public static boolean allowTeleportWhenFalling;
// // Challenges - show or remove completed on-time challenges
// public static boolean removeCompleteOntimeChallenges;
// public static boolean addCompletedGlow;
//
// // Use Economy
// public static boolean useEconomy;
//
// // Use physics when pasting schematic blocks
// public static boolean usePhysics;
//
// // Falling blocked commands
// public static List<String> fallingCommandBlockList;
// public static boolean resetEnderChest;
// public static boolean updateCheck;
// public static long islandStartX;
// public static long islandStartZ;
// public static boolean allowNetherPvP;
// public static int maxHomes;
// public static boolean immediateTeleport;
// public static int debug;
// public static boolean respawnAtHome;
// public static boolean restrictWither;
// public static List<String> startCommands;
// public static boolean useWarpPanel;
// public static List<EntityType> mobWhiteList = new ArrayList<EntityType>();
// public static boolean muteDeathMessages;
// public static boolean allowFireSpread;
// public static int gridHeight;
// public static boolean allowBreakBlocks;
// public static boolean allowPlaceBlocks;
// public static boolean allowBedUse;
// public static boolean allowBucketUse;
// public static boolean allowShearing;
// public static boolean allowEnderPearls;
// public static boolean allowDoorUse;
// public static boolean allowLeverButtonUse;
// public static boolean allowCropTrample;
// public static boolean allowChestAccess;
// public static boolean allowFurnaceUse;
// public static boolean allowRedStone;
// public static boolean allowMusic;
// public static boolean allowCrafting;
// public static boolean allowBrewing;
// public static boolean allowGateUse;
// public static boolean allowMobHarm;
// public static boolean allowFlowIn;
// public static boolean allowFlowOut;
// public static int spawnHeight;
// public static boolean allowTNTDamage;
// public static boolean allowChestDamage;
// public static List<String> bannedCommandList;
//
//
// public static boolean allowHorseInvAccess;
// public static boolean createEnd;
// public static double endPortalProb;
// public static long spawnCenterX;
// public static long spawnCenterZ;
// public static boolean allowFallDamage;
// public static boolean createBiomes;
// public static boolean growTrees;
// public static Sound warpSound;
// }
| import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.TreeMap;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.TreeType;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SpawnEggMeta;
import org.bukkit.material.SpawnEgg;
import com.wasteofplastic.askygrid.Settings; | if (type.isAlive()) {
//Bukkit.getLogger().info("DEBUG: " + type.toString() + "=>" + (index));
spawnEggData.put(type.toString(), index);
}
index++;
}
}
/**
* @param size
*/
public SkyGridPop(int size) {
this.size = size;
// Work out if SpawnEgg method is available
if (getMethod("SpawnEggMeta", ItemMeta.class) != null) {
spawnEggMeta = true;
}
}
@Override
public void populate(World world, Random random, Chunk chunk) {
if (DEBUG)
Bukkit.getLogger().info("DEBUG: populate chunk");
boolean chunkHasPortal = false;
int r = 0;
for (int x = 0; x < 16; x += 4) {
for (int y = 0; y < size; y += 4) {
for (int z = 0; z < 16; z +=4) {
Block b = chunk.getBlock(x, y, z);
// Do an end portal check | // Path: src/com/wasteofplastic/askygrid/Settings.java
// public class Settings {
// // Permission prefix
// public final static String PERMPREFIX = "askygrid.";
// // The island command
// public final static String ISLANDCOMMAND = "asg";
// // The challenge command
// public static final String CHALLENGECOMMAND = "asgc";
// // The spawn command (Essentials spawn for example)
// public final static String SPAWNCOMMAND = "spawn";
// // Admin command
// public static final String ADMINCOMMAND = "asgadmin";
//
// public static Set<String> challengeList;
// public static int waiverAmount;
// public static List<String> challengeLevels;
// public static String worldName;
// public static int monsterSpawnLimit;
// public static int animalSpawnLimit;
// public static int waterAnimalSpawnLimit;
// // IslandGuard settings
// public static boolean allowPvP;
// public static int spawnDistance;
// public static int islandXOffset;
// public static int islandZOffset;
// public static int claim_protectionRange;
// public static Double startingMoney;
// public static boolean resetMoney;
//
// // public static boolean ultraSafeBoats;
// public static boolean logInRemoveMobs;
// public static boolean removeMobs;
//
// // Challenge completion broadcast
// public static boolean broadcastMessages;
// // Nether world
// public static boolean createNether;
// public static boolean clearInventory;
// // Use control panel for /island
// public static boolean useControlPanel;
// // Prevent /island when falling
// public static boolean allowTeleportWhenFalling;
// // Challenges - show or remove completed on-time challenges
// public static boolean removeCompleteOntimeChallenges;
// public static boolean addCompletedGlow;
//
// // Use Economy
// public static boolean useEconomy;
//
// // Use physics when pasting schematic blocks
// public static boolean usePhysics;
//
// // Falling blocked commands
// public static List<String> fallingCommandBlockList;
// public static boolean resetEnderChest;
// public static boolean updateCheck;
// public static long islandStartX;
// public static long islandStartZ;
// public static boolean allowNetherPvP;
// public static int maxHomes;
// public static boolean immediateTeleport;
// public static int debug;
// public static boolean respawnAtHome;
// public static boolean restrictWither;
// public static List<String> startCommands;
// public static boolean useWarpPanel;
// public static List<EntityType> mobWhiteList = new ArrayList<EntityType>();
// public static boolean muteDeathMessages;
// public static boolean allowFireSpread;
// public static int gridHeight;
// public static boolean allowBreakBlocks;
// public static boolean allowPlaceBlocks;
// public static boolean allowBedUse;
// public static boolean allowBucketUse;
// public static boolean allowShearing;
// public static boolean allowEnderPearls;
// public static boolean allowDoorUse;
// public static boolean allowLeverButtonUse;
// public static boolean allowCropTrample;
// public static boolean allowChestAccess;
// public static boolean allowFurnaceUse;
// public static boolean allowRedStone;
// public static boolean allowMusic;
// public static boolean allowCrafting;
// public static boolean allowBrewing;
// public static boolean allowGateUse;
// public static boolean allowMobHarm;
// public static boolean allowFlowIn;
// public static boolean allowFlowOut;
// public static int spawnHeight;
// public static boolean allowTNTDamage;
// public static boolean allowChestDamage;
// public static List<String> bannedCommandList;
//
//
// public static boolean allowHorseInvAccess;
// public static boolean createEnd;
// public static double endPortalProb;
// public static long spawnCenterX;
// public static long spawnCenterZ;
// public static boolean allowFallDamage;
// public static boolean createBiomes;
// public static boolean growTrees;
// public static Sound warpSound;
// }
// Path: src/com/wasteofplastic/askygrid/generators/SkyGridPop.java
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.TreeMap;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.TreeType;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SpawnEggMeta;
import org.bukkit.material.SpawnEgg;
import com.wasteofplastic.askygrid.Settings;
if (type.isAlive()) {
//Bukkit.getLogger().info("DEBUG: " + type.toString() + "=>" + (index));
spawnEggData.put(type.toString(), index);
}
index++;
}
}
/**
* @param size
*/
public SkyGridPop(int size) {
this.size = size;
// Work out if SpawnEgg method is available
if (getMethod("SpawnEggMeta", ItemMeta.class) != null) {
spawnEggMeta = true;
}
}
@Override
public void populate(World world, Random random, Chunk chunk) {
if (DEBUG)
Bukkit.getLogger().info("DEBUG: populate chunk");
boolean chunkHasPortal = false;
int r = 0;
for (int x = 0; x < 16; x += 4) {
for (int y = 0; y < size; y += 4) {
for (int z = 0; z < 16; z +=4) {
Block b = chunk.getBlock(x, y, z);
// Do an end portal check | if (Settings.createEnd && world.getEnvironment().equals(Environment.NORMAL) |
idobrusin/RocLang | RocLang/robotcontrol.parent/robotcontrol.tests/xtend-gen/robotcontrol/tests/RocParsingTest.java | // Path: RocLang/robotcontrol.parent/robotcontrol/src-gen/robotcontrol/roc/Program.java
// public interface Program extends EObject
// {
// /**
// * Returns the value of the '<em><b>Movements</b></em>' containment reference list.
// * The list contents are of type {@link robotcontrol.roc.Movement}.
// * <!-- begin-user-doc -->
// * <p>
// * If the meaning of the '<em>Movements</em>' containment reference list isn't clear,
// * there really should be more of a description here...
// * </p>
// * <!-- end-user-doc -->
// * @return the value of the '<em>Movements</em>' containment reference list.
// * @see robotcontrol.roc.RocPackage#getProgram_Movements()
// * @model containment="true"
// * @generated
// */
// EList<Movement> getMovements();
//
// } // Program
//
// Path: RocLang/robotcontrol.parent/robotcontrol.tests/src-gen/robotcontrol/tests/RocInjectorProvider.java
// public class RocInjectorProvider implements IInjectorProvider, IRegistryConfigurator {
//
// protected GlobalStateMemento stateBeforeInjectorCreation;
// protected GlobalStateMemento stateAfterInjectorCreation;
// protected Injector injector;
//
// static {
// GlobalRegistries.initializeDefaults();
// }
//
// @Override
// public Injector getInjector() {
// if (injector == null) {
// stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
// this.injector = internalCreateInjector();
// stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
// }
// return injector;
// }
//
// protected Injector internalCreateInjector() {
// return new RocStandaloneSetup() {
// @Override
// public Injector createInjector() {
// return Guice.createInjector(createRuntimeModule());
// }
// }.createInjectorAndDoEMFRegistration();
// }
//
// protected RocRuntimeModule createRuntimeModule() {
// // make it work also with Maven/Tycho and OSGI
// // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=493672
// return new RocRuntimeModule() {
// @Override
// public ClassLoader bindClassLoaderToInstance() {
// return RocInjectorProvider.class
// .getClassLoader();
// }
// };
// }
//
// @Override
// public void restoreRegistry() {
// stateBeforeInjectorCreation.restoreGlobalState();
// }
//
// @Override
// public void setupRegistry() {
// getInjector();
// stateAfterInjectorCreation.restoreGlobalState();
// }
// }
| import com.google.inject.Inject;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.junit4.InjectWith;
import org.eclipse.xtext.junit4.XtextRunner;
import org.eclipse.xtext.junit4.util.ParseHelper;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import robotcontrol.roc.Program;
import robotcontrol.tests.RocInjectorProvider; | /**
* generated by Xtext 2.10.0
*/
package robotcontrol.tests;
@RunWith(XtextRunner.class)
@InjectWith(RocInjectorProvider.class)
@SuppressWarnings("all")
public class RocParsingTest {
@Inject | // Path: RocLang/robotcontrol.parent/robotcontrol/src-gen/robotcontrol/roc/Program.java
// public interface Program extends EObject
// {
// /**
// * Returns the value of the '<em><b>Movements</b></em>' containment reference list.
// * The list contents are of type {@link robotcontrol.roc.Movement}.
// * <!-- begin-user-doc -->
// * <p>
// * If the meaning of the '<em>Movements</em>' containment reference list isn't clear,
// * there really should be more of a description here...
// * </p>
// * <!-- end-user-doc -->
// * @return the value of the '<em>Movements</em>' containment reference list.
// * @see robotcontrol.roc.RocPackage#getProgram_Movements()
// * @model containment="true"
// * @generated
// */
// EList<Movement> getMovements();
//
// } // Program
//
// Path: RocLang/robotcontrol.parent/robotcontrol.tests/src-gen/robotcontrol/tests/RocInjectorProvider.java
// public class RocInjectorProvider implements IInjectorProvider, IRegistryConfigurator {
//
// protected GlobalStateMemento stateBeforeInjectorCreation;
// protected GlobalStateMemento stateAfterInjectorCreation;
// protected Injector injector;
//
// static {
// GlobalRegistries.initializeDefaults();
// }
//
// @Override
// public Injector getInjector() {
// if (injector == null) {
// stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
// this.injector = internalCreateInjector();
// stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
// }
// return injector;
// }
//
// protected Injector internalCreateInjector() {
// return new RocStandaloneSetup() {
// @Override
// public Injector createInjector() {
// return Guice.createInjector(createRuntimeModule());
// }
// }.createInjectorAndDoEMFRegistration();
// }
//
// protected RocRuntimeModule createRuntimeModule() {
// // make it work also with Maven/Tycho and OSGI
// // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=493672
// return new RocRuntimeModule() {
// @Override
// public ClassLoader bindClassLoaderToInstance() {
// return RocInjectorProvider.class
// .getClassLoader();
// }
// };
// }
//
// @Override
// public void restoreRegistry() {
// stateBeforeInjectorCreation.restoreGlobalState();
// }
//
// @Override
// public void setupRegistry() {
// getInjector();
// stateAfterInjectorCreation.restoreGlobalState();
// }
// }
// Path: RocLang/robotcontrol.parent/robotcontrol.tests/xtend-gen/robotcontrol/tests/RocParsingTest.java
import com.google.inject.Inject;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.junit4.InjectWith;
import org.eclipse.xtext.junit4.XtextRunner;
import org.eclipse.xtext.junit4.util.ParseHelper;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import robotcontrol.roc.Program;
import robotcontrol.tests.RocInjectorProvider;
/**
* generated by Xtext 2.10.0
*/
package robotcontrol.tests;
@RunWith(XtextRunner.class)
@InjectWith(RocInjectorProvider.class)
@SuppressWarnings("all")
public class RocParsingTest {
@Inject | private ParseHelper<Program> parseHelper; |
idobrusin/RocLang | RocLang/robotcontrol.parent/robotcontrol.tests/src-gen/robotcontrol/tests/RocInjectorProvider.java | // Path: RocLang/robotcontrol.parent/robotcontrol/xtend-gen/robotcontrol/RocRuntimeModule.java
// @SuppressWarnings("all")
// public class RocRuntimeModule extends AbstractRocRuntimeModule {
// }
//
// Path: RocLang/robotcontrol.parent/robotcontrol/xtend-gen/robotcontrol/RocStandaloneSetup.java
// @SuppressWarnings("all")
// public class RocStandaloneSetup extends RocStandaloneSetupGenerated {
// public static void doSetup() {
// RocStandaloneSetup _rocStandaloneSetup = new RocStandaloneSetup();
// _rocStandaloneSetup.createInjectorAndDoEMFRegistration();
// }
// }
| import com.google.inject.Guice;
import com.google.inject.Injector;
import org.eclipse.xtext.junit4.GlobalRegistries;
import org.eclipse.xtext.junit4.GlobalRegistries.GlobalStateMemento;
import org.eclipse.xtext.junit4.IInjectorProvider;
import org.eclipse.xtext.junit4.IRegistryConfigurator;
import robotcontrol.RocRuntimeModule;
import robotcontrol.RocStandaloneSetup; | /*
* generated by Xtext 2.10.0
*/
package robotcontrol.tests;
public class RocInjectorProvider implements IInjectorProvider, IRegistryConfigurator {
protected GlobalStateMemento stateBeforeInjectorCreation;
protected GlobalStateMemento stateAfterInjectorCreation;
protected Injector injector;
static {
GlobalRegistries.initializeDefaults();
}
@Override
public Injector getInjector() {
if (injector == null) {
stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
this.injector = internalCreateInjector();
stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
}
return injector;
}
protected Injector internalCreateInjector() { | // Path: RocLang/robotcontrol.parent/robotcontrol/xtend-gen/robotcontrol/RocRuntimeModule.java
// @SuppressWarnings("all")
// public class RocRuntimeModule extends AbstractRocRuntimeModule {
// }
//
// Path: RocLang/robotcontrol.parent/robotcontrol/xtend-gen/robotcontrol/RocStandaloneSetup.java
// @SuppressWarnings("all")
// public class RocStandaloneSetup extends RocStandaloneSetupGenerated {
// public static void doSetup() {
// RocStandaloneSetup _rocStandaloneSetup = new RocStandaloneSetup();
// _rocStandaloneSetup.createInjectorAndDoEMFRegistration();
// }
// }
// Path: RocLang/robotcontrol.parent/robotcontrol.tests/src-gen/robotcontrol/tests/RocInjectorProvider.java
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.eclipse.xtext.junit4.GlobalRegistries;
import org.eclipse.xtext.junit4.GlobalRegistries.GlobalStateMemento;
import org.eclipse.xtext.junit4.IInjectorProvider;
import org.eclipse.xtext.junit4.IRegistryConfigurator;
import robotcontrol.RocRuntimeModule;
import robotcontrol.RocStandaloneSetup;
/*
* generated by Xtext 2.10.0
*/
package robotcontrol.tests;
public class RocInjectorProvider implements IInjectorProvider, IRegistryConfigurator {
protected GlobalStateMemento stateBeforeInjectorCreation;
protected GlobalStateMemento stateAfterInjectorCreation;
protected Injector injector;
static {
GlobalRegistries.initializeDefaults();
}
@Override
public Injector getInjector() {
if (injector == null) {
stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
this.injector = internalCreateInjector();
stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
}
return injector;
}
protected Injector internalCreateInjector() { | return new RocStandaloneSetup() { |
idobrusin/RocLang | RocLang/robotcontrol.parent/robotcontrol.tests/src-gen/robotcontrol/tests/RocInjectorProvider.java | // Path: RocLang/robotcontrol.parent/robotcontrol/xtend-gen/robotcontrol/RocRuntimeModule.java
// @SuppressWarnings("all")
// public class RocRuntimeModule extends AbstractRocRuntimeModule {
// }
//
// Path: RocLang/robotcontrol.parent/robotcontrol/xtend-gen/robotcontrol/RocStandaloneSetup.java
// @SuppressWarnings("all")
// public class RocStandaloneSetup extends RocStandaloneSetupGenerated {
// public static void doSetup() {
// RocStandaloneSetup _rocStandaloneSetup = new RocStandaloneSetup();
// _rocStandaloneSetup.createInjectorAndDoEMFRegistration();
// }
// }
| import com.google.inject.Guice;
import com.google.inject.Injector;
import org.eclipse.xtext.junit4.GlobalRegistries;
import org.eclipse.xtext.junit4.GlobalRegistries.GlobalStateMemento;
import org.eclipse.xtext.junit4.IInjectorProvider;
import org.eclipse.xtext.junit4.IRegistryConfigurator;
import robotcontrol.RocRuntimeModule;
import robotcontrol.RocStandaloneSetup; | /*
* generated by Xtext 2.10.0
*/
package robotcontrol.tests;
public class RocInjectorProvider implements IInjectorProvider, IRegistryConfigurator {
protected GlobalStateMemento stateBeforeInjectorCreation;
protected GlobalStateMemento stateAfterInjectorCreation;
protected Injector injector;
static {
GlobalRegistries.initializeDefaults();
}
@Override
public Injector getInjector() {
if (injector == null) {
stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
this.injector = internalCreateInjector();
stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
}
return injector;
}
protected Injector internalCreateInjector() {
return new RocStandaloneSetup() {
@Override
public Injector createInjector() {
return Guice.createInjector(createRuntimeModule());
}
}.createInjectorAndDoEMFRegistration();
}
| // Path: RocLang/robotcontrol.parent/robotcontrol/xtend-gen/robotcontrol/RocRuntimeModule.java
// @SuppressWarnings("all")
// public class RocRuntimeModule extends AbstractRocRuntimeModule {
// }
//
// Path: RocLang/robotcontrol.parent/robotcontrol/xtend-gen/robotcontrol/RocStandaloneSetup.java
// @SuppressWarnings("all")
// public class RocStandaloneSetup extends RocStandaloneSetupGenerated {
// public static void doSetup() {
// RocStandaloneSetup _rocStandaloneSetup = new RocStandaloneSetup();
// _rocStandaloneSetup.createInjectorAndDoEMFRegistration();
// }
// }
// Path: RocLang/robotcontrol.parent/robotcontrol.tests/src-gen/robotcontrol/tests/RocInjectorProvider.java
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.eclipse.xtext.junit4.GlobalRegistries;
import org.eclipse.xtext.junit4.GlobalRegistries.GlobalStateMemento;
import org.eclipse.xtext.junit4.IInjectorProvider;
import org.eclipse.xtext.junit4.IRegistryConfigurator;
import robotcontrol.RocRuntimeModule;
import robotcontrol.RocStandaloneSetup;
/*
* generated by Xtext 2.10.0
*/
package robotcontrol.tests;
public class RocInjectorProvider implements IInjectorProvider, IRegistryConfigurator {
protected GlobalStateMemento stateBeforeInjectorCreation;
protected GlobalStateMemento stateAfterInjectorCreation;
protected Injector injector;
static {
GlobalRegistries.initializeDefaults();
}
@Override
public Injector getInjector() {
if (injector == null) {
stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
this.injector = internalCreateInjector();
stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
}
return injector;
}
protected Injector internalCreateInjector() {
return new RocStandaloneSetup() {
@Override
public Injector createInjector() {
return Guice.createInjector(createRuntimeModule());
}
}.createInjectorAndDoEMFRegistration();
}
| protected RocRuntimeModule createRuntimeModule() { |
idobrusin/RocLang | RocLang/robotcontrol.parent/robotcontrol.ui/src-gen/robotcontrol/ui/internal/RobotcontrolActivator.java | // Path: RocLang/robotcontrol.parent/robotcontrol/xtend-gen/robotcontrol/RocRuntimeModule.java
// @SuppressWarnings("all")
// public class RocRuntimeModule extends AbstractRocRuntimeModule {
// }
//
// Path: RocLang/robotcontrol.parent/robotcontrol.ui/xtend-gen/robotcontrol/ui/RocUiModule.java
// @FinalFieldsConstructor
// @SuppressWarnings("all")
// public class RocUiModule extends AbstractRocUiModule {
// public RocUiModule(final AbstractUIPlugin plugin) {
// super(plugin);
// }
// }
| import com.google.common.collect.Maps;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import java.util.Collections;
import java.util.Map;
import org.apache.log4j.Logger;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.xtext.ui.shared.SharedStateModule;
import org.eclipse.xtext.util.Modules2;
import org.osgi.framework.BundleContext;
import robotcontrol.RocRuntimeModule;
import robotcontrol.ui.RocUiModule; | public static RobotcontrolActivator getInstance() {
return INSTANCE;
}
public Injector getInjector(String language) {
synchronized (injectors) {
Injector injector = injectors.get(language);
if (injector == null) {
injectors.put(language, injector = createInjector(language));
}
return injector;
}
}
protected Injector createInjector(String language) {
try {
Module runtimeModule = getRuntimeModule(language);
Module sharedStateModule = getSharedStateModule();
Module uiModule = getUiModule(language);
Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
return Guice.createInjector(mergedModule);
} catch (Exception e) {
logger.error("Failed to create injector for " + language);
logger.error(e.getMessage(), e);
throw new RuntimeException("Failed to create injector for " + language, e);
}
}
protected Module getRuntimeModule(String grammar) {
if (ROBOTCONTROL_ROC.equals(grammar)) { | // Path: RocLang/robotcontrol.parent/robotcontrol/xtend-gen/robotcontrol/RocRuntimeModule.java
// @SuppressWarnings("all")
// public class RocRuntimeModule extends AbstractRocRuntimeModule {
// }
//
// Path: RocLang/robotcontrol.parent/robotcontrol.ui/xtend-gen/robotcontrol/ui/RocUiModule.java
// @FinalFieldsConstructor
// @SuppressWarnings("all")
// public class RocUiModule extends AbstractRocUiModule {
// public RocUiModule(final AbstractUIPlugin plugin) {
// super(plugin);
// }
// }
// Path: RocLang/robotcontrol.parent/robotcontrol.ui/src-gen/robotcontrol/ui/internal/RobotcontrolActivator.java
import com.google.common.collect.Maps;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import java.util.Collections;
import java.util.Map;
import org.apache.log4j.Logger;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.xtext.ui.shared.SharedStateModule;
import org.eclipse.xtext.util.Modules2;
import org.osgi.framework.BundleContext;
import robotcontrol.RocRuntimeModule;
import robotcontrol.ui.RocUiModule;
public static RobotcontrolActivator getInstance() {
return INSTANCE;
}
public Injector getInjector(String language) {
synchronized (injectors) {
Injector injector = injectors.get(language);
if (injector == null) {
injectors.put(language, injector = createInjector(language));
}
return injector;
}
}
protected Injector createInjector(String language) {
try {
Module runtimeModule = getRuntimeModule(language);
Module sharedStateModule = getSharedStateModule();
Module uiModule = getUiModule(language);
Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
return Guice.createInjector(mergedModule);
} catch (Exception e) {
logger.error("Failed to create injector for " + language);
logger.error(e.getMessage(), e);
throw new RuntimeException("Failed to create injector for " + language, e);
}
}
protected Module getRuntimeModule(String grammar) {
if (ROBOTCONTROL_ROC.equals(grammar)) { | return new RocRuntimeModule(); |
idobrusin/RocLang | RocLang/robotcontrol.parent/robotcontrol.ui/src-gen/robotcontrol/ui/internal/RobotcontrolActivator.java | // Path: RocLang/robotcontrol.parent/robotcontrol/xtend-gen/robotcontrol/RocRuntimeModule.java
// @SuppressWarnings("all")
// public class RocRuntimeModule extends AbstractRocRuntimeModule {
// }
//
// Path: RocLang/robotcontrol.parent/robotcontrol.ui/xtend-gen/robotcontrol/ui/RocUiModule.java
// @FinalFieldsConstructor
// @SuppressWarnings("all")
// public class RocUiModule extends AbstractRocUiModule {
// public RocUiModule(final AbstractUIPlugin plugin) {
// super(plugin);
// }
// }
| import com.google.common.collect.Maps;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import java.util.Collections;
import java.util.Map;
import org.apache.log4j.Logger;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.xtext.ui.shared.SharedStateModule;
import org.eclipse.xtext.util.Modules2;
import org.osgi.framework.BundleContext;
import robotcontrol.RocRuntimeModule;
import robotcontrol.ui.RocUiModule; | if (injector == null) {
injectors.put(language, injector = createInjector(language));
}
return injector;
}
}
protected Injector createInjector(String language) {
try {
Module runtimeModule = getRuntimeModule(language);
Module sharedStateModule = getSharedStateModule();
Module uiModule = getUiModule(language);
Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
return Guice.createInjector(mergedModule);
} catch (Exception e) {
logger.error("Failed to create injector for " + language);
logger.error(e.getMessage(), e);
throw new RuntimeException("Failed to create injector for " + language, e);
}
}
protected Module getRuntimeModule(String grammar) {
if (ROBOTCONTROL_ROC.equals(grammar)) {
return new RocRuntimeModule();
}
throw new IllegalArgumentException(grammar);
}
protected Module getUiModule(String grammar) {
if (ROBOTCONTROL_ROC.equals(grammar)) { | // Path: RocLang/robotcontrol.parent/robotcontrol/xtend-gen/robotcontrol/RocRuntimeModule.java
// @SuppressWarnings("all")
// public class RocRuntimeModule extends AbstractRocRuntimeModule {
// }
//
// Path: RocLang/robotcontrol.parent/robotcontrol.ui/xtend-gen/robotcontrol/ui/RocUiModule.java
// @FinalFieldsConstructor
// @SuppressWarnings("all")
// public class RocUiModule extends AbstractRocUiModule {
// public RocUiModule(final AbstractUIPlugin plugin) {
// super(plugin);
// }
// }
// Path: RocLang/robotcontrol.parent/robotcontrol.ui/src-gen/robotcontrol/ui/internal/RobotcontrolActivator.java
import com.google.common.collect.Maps;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import java.util.Collections;
import java.util.Map;
import org.apache.log4j.Logger;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.xtext.ui.shared.SharedStateModule;
import org.eclipse.xtext.util.Modules2;
import org.osgi.framework.BundleContext;
import robotcontrol.RocRuntimeModule;
import robotcontrol.ui.RocUiModule;
if (injector == null) {
injectors.put(language, injector = createInjector(language));
}
return injector;
}
}
protected Injector createInjector(String language) {
try {
Module runtimeModule = getRuntimeModule(language);
Module sharedStateModule = getSharedStateModule();
Module uiModule = getUiModule(language);
Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
return Guice.createInjector(mergedModule);
} catch (Exception e) {
logger.error("Failed to create injector for " + language);
logger.error(e.getMessage(), e);
throw new RuntimeException("Failed to create injector for " + language, e);
}
}
protected Module getRuntimeModule(String grammar) {
if (ROBOTCONTROL_ROC.equals(grammar)) {
return new RocRuntimeModule();
}
throw new IllegalArgumentException(grammar);
}
protected Module getUiModule(String grammar) {
if (ROBOTCONTROL_ROC.equals(grammar)) { | return new RocUiModule(this); |
idobrusin/RocLang | RocLang/robotcontrol.parent/robotcontrol.ui.tests/src-gen/robotcontrol/ui/tests/RocUiInjectorProvider.java | // Path: RocLang/robotcontrol.parent/robotcontrol.ui/src-gen/robotcontrol/ui/internal/RobotcontrolActivator.java
// public class RobotcontrolActivator extends AbstractUIPlugin {
//
// public static final String ROBOTCONTROL_ROC = "robotcontrol.Roc";
//
// private static final Logger logger = Logger.getLogger(RobotcontrolActivator.class);
//
// private static RobotcontrolActivator INSTANCE;
//
// private Map<String, Injector> injectors = Collections.synchronizedMap(Maps.<String, Injector> newHashMapWithExpectedSize(1));
//
// @Override
// public void start(BundleContext context) throws Exception {
// super.start(context);
// INSTANCE = this;
// }
//
// @Override
// public void stop(BundleContext context) throws Exception {
// injectors.clear();
// INSTANCE = null;
// super.stop(context);
// }
//
// public static RobotcontrolActivator getInstance() {
// return INSTANCE;
// }
//
// public Injector getInjector(String language) {
// synchronized (injectors) {
// Injector injector = injectors.get(language);
// if (injector == null) {
// injectors.put(language, injector = createInjector(language));
// }
// return injector;
// }
// }
//
// protected Injector createInjector(String language) {
// try {
// Module runtimeModule = getRuntimeModule(language);
// Module sharedStateModule = getSharedStateModule();
// Module uiModule = getUiModule(language);
// Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
// return Guice.createInjector(mergedModule);
// } catch (Exception e) {
// logger.error("Failed to create injector for " + language);
// logger.error(e.getMessage(), e);
// throw new RuntimeException("Failed to create injector for " + language, e);
// }
// }
//
// protected Module getRuntimeModule(String grammar) {
// if (ROBOTCONTROL_ROC.equals(grammar)) {
// return new RocRuntimeModule();
// }
// throw new IllegalArgumentException(grammar);
// }
//
// protected Module getUiModule(String grammar) {
// if (ROBOTCONTROL_ROC.equals(grammar)) {
// return new RocUiModule(this);
// }
// throw new IllegalArgumentException(grammar);
// }
//
// protected Module getSharedStateModule() {
// return new SharedStateModule();
// }
//
// }
| import com.google.inject.Injector;
import org.eclipse.xtext.junit4.IInjectorProvider;
import robotcontrol.ui.internal.RobotcontrolActivator; | /*
* generated by Xtext 2.10.0
*/
package robotcontrol.ui.tests;
public class RocUiInjectorProvider implements IInjectorProvider {
@Override
public Injector getInjector() { | // Path: RocLang/robotcontrol.parent/robotcontrol.ui/src-gen/robotcontrol/ui/internal/RobotcontrolActivator.java
// public class RobotcontrolActivator extends AbstractUIPlugin {
//
// public static final String ROBOTCONTROL_ROC = "robotcontrol.Roc";
//
// private static final Logger logger = Logger.getLogger(RobotcontrolActivator.class);
//
// private static RobotcontrolActivator INSTANCE;
//
// private Map<String, Injector> injectors = Collections.synchronizedMap(Maps.<String, Injector> newHashMapWithExpectedSize(1));
//
// @Override
// public void start(BundleContext context) throws Exception {
// super.start(context);
// INSTANCE = this;
// }
//
// @Override
// public void stop(BundleContext context) throws Exception {
// injectors.clear();
// INSTANCE = null;
// super.stop(context);
// }
//
// public static RobotcontrolActivator getInstance() {
// return INSTANCE;
// }
//
// public Injector getInjector(String language) {
// synchronized (injectors) {
// Injector injector = injectors.get(language);
// if (injector == null) {
// injectors.put(language, injector = createInjector(language));
// }
// return injector;
// }
// }
//
// protected Injector createInjector(String language) {
// try {
// Module runtimeModule = getRuntimeModule(language);
// Module sharedStateModule = getSharedStateModule();
// Module uiModule = getUiModule(language);
// Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
// return Guice.createInjector(mergedModule);
// } catch (Exception e) {
// logger.error("Failed to create injector for " + language);
// logger.error(e.getMessage(), e);
// throw new RuntimeException("Failed to create injector for " + language, e);
// }
// }
//
// protected Module getRuntimeModule(String grammar) {
// if (ROBOTCONTROL_ROC.equals(grammar)) {
// return new RocRuntimeModule();
// }
// throw new IllegalArgumentException(grammar);
// }
//
// protected Module getUiModule(String grammar) {
// if (ROBOTCONTROL_ROC.equals(grammar)) {
// return new RocUiModule(this);
// }
// throw new IllegalArgumentException(grammar);
// }
//
// protected Module getSharedStateModule() {
// return new SharedStateModule();
// }
//
// }
// Path: RocLang/robotcontrol.parent/robotcontrol.ui.tests/src-gen/robotcontrol/ui/tests/RocUiInjectorProvider.java
import com.google.inject.Injector;
import org.eclipse.xtext.junit4.IInjectorProvider;
import robotcontrol.ui.internal.RobotcontrolActivator;
/*
* generated by Xtext 2.10.0
*/
package robotcontrol.ui.tests;
public class RocUiInjectorProvider implements IInjectorProvider {
@Override
public Injector getInjector() { | return RobotcontrolActivator.getInstance().getInjector("robotcontrol.Roc"); |
idobrusin/RocLang | RocLang/robotcontrol.parent/robotcontrol.ui/src-gen/robotcontrol/ui/RocExecutableExtensionFactory.java | // Path: RocLang/robotcontrol.parent/robotcontrol.ui/src-gen/robotcontrol/ui/internal/RobotcontrolActivator.java
// public class RobotcontrolActivator extends AbstractUIPlugin {
//
// public static final String ROBOTCONTROL_ROC = "robotcontrol.Roc";
//
// private static final Logger logger = Logger.getLogger(RobotcontrolActivator.class);
//
// private static RobotcontrolActivator INSTANCE;
//
// private Map<String, Injector> injectors = Collections.synchronizedMap(Maps.<String, Injector> newHashMapWithExpectedSize(1));
//
// @Override
// public void start(BundleContext context) throws Exception {
// super.start(context);
// INSTANCE = this;
// }
//
// @Override
// public void stop(BundleContext context) throws Exception {
// injectors.clear();
// INSTANCE = null;
// super.stop(context);
// }
//
// public static RobotcontrolActivator getInstance() {
// return INSTANCE;
// }
//
// public Injector getInjector(String language) {
// synchronized (injectors) {
// Injector injector = injectors.get(language);
// if (injector == null) {
// injectors.put(language, injector = createInjector(language));
// }
// return injector;
// }
// }
//
// protected Injector createInjector(String language) {
// try {
// Module runtimeModule = getRuntimeModule(language);
// Module sharedStateModule = getSharedStateModule();
// Module uiModule = getUiModule(language);
// Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
// return Guice.createInjector(mergedModule);
// } catch (Exception e) {
// logger.error("Failed to create injector for " + language);
// logger.error(e.getMessage(), e);
// throw new RuntimeException("Failed to create injector for " + language, e);
// }
// }
//
// protected Module getRuntimeModule(String grammar) {
// if (ROBOTCONTROL_ROC.equals(grammar)) {
// return new RocRuntimeModule();
// }
// throw new IllegalArgumentException(grammar);
// }
//
// protected Module getUiModule(String grammar) {
// if (ROBOTCONTROL_ROC.equals(grammar)) {
// return new RocUiModule(this);
// }
// throw new IllegalArgumentException(grammar);
// }
//
// protected Module getSharedStateModule() {
// return new SharedStateModule();
// }
//
// }
| import robotcontrol.ui.internal.RobotcontrolActivator;
import com.google.inject.Injector;
import org.eclipse.xtext.ui.guice.AbstractGuiceAwareExecutableExtensionFactory;
import org.osgi.framework.Bundle; | /*
* generated by Xtext 2.10.0
*/
package robotcontrol.ui;
/**
* This class was generated. Customizations should only happen in a newly
* introduced subclass.
*/
public class RocExecutableExtensionFactory extends AbstractGuiceAwareExecutableExtensionFactory {
@Override
protected Bundle getBundle() { | // Path: RocLang/robotcontrol.parent/robotcontrol.ui/src-gen/robotcontrol/ui/internal/RobotcontrolActivator.java
// public class RobotcontrolActivator extends AbstractUIPlugin {
//
// public static final String ROBOTCONTROL_ROC = "robotcontrol.Roc";
//
// private static final Logger logger = Logger.getLogger(RobotcontrolActivator.class);
//
// private static RobotcontrolActivator INSTANCE;
//
// private Map<String, Injector> injectors = Collections.synchronizedMap(Maps.<String, Injector> newHashMapWithExpectedSize(1));
//
// @Override
// public void start(BundleContext context) throws Exception {
// super.start(context);
// INSTANCE = this;
// }
//
// @Override
// public void stop(BundleContext context) throws Exception {
// injectors.clear();
// INSTANCE = null;
// super.stop(context);
// }
//
// public static RobotcontrolActivator getInstance() {
// return INSTANCE;
// }
//
// public Injector getInjector(String language) {
// synchronized (injectors) {
// Injector injector = injectors.get(language);
// if (injector == null) {
// injectors.put(language, injector = createInjector(language));
// }
// return injector;
// }
// }
//
// protected Injector createInjector(String language) {
// try {
// Module runtimeModule = getRuntimeModule(language);
// Module sharedStateModule = getSharedStateModule();
// Module uiModule = getUiModule(language);
// Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
// return Guice.createInjector(mergedModule);
// } catch (Exception e) {
// logger.error("Failed to create injector for " + language);
// logger.error(e.getMessage(), e);
// throw new RuntimeException("Failed to create injector for " + language, e);
// }
// }
//
// protected Module getRuntimeModule(String grammar) {
// if (ROBOTCONTROL_ROC.equals(grammar)) {
// return new RocRuntimeModule();
// }
// throw new IllegalArgumentException(grammar);
// }
//
// protected Module getUiModule(String grammar) {
// if (ROBOTCONTROL_ROC.equals(grammar)) {
// return new RocUiModule(this);
// }
// throw new IllegalArgumentException(grammar);
// }
//
// protected Module getSharedStateModule() {
// return new SharedStateModule();
// }
//
// }
// Path: RocLang/robotcontrol.parent/robotcontrol.ui/src-gen/robotcontrol/ui/RocExecutableExtensionFactory.java
import robotcontrol.ui.internal.RobotcontrolActivator;
import com.google.inject.Injector;
import org.eclipse.xtext.ui.guice.AbstractGuiceAwareExecutableExtensionFactory;
import org.osgi.framework.Bundle;
/*
* generated by Xtext 2.10.0
*/
package robotcontrol.ui;
/**
* This class was generated. Customizations should only happen in a newly
* introduced subclass.
*/
public class RocExecutableExtensionFactory extends AbstractGuiceAwareExecutableExtensionFactory {
@Override
protected Bundle getBundle() { | return RobotcontrolActivator.getInstance().getBundle(); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/domain/resolver/ManualSignalResolver.java | // Path: src/main/java/org/nextrtc/signalingserver/cases/SignalHandler.java
// public interface SignalHandler {
// void execute(InternalMessage message);
// }
| import org.nextrtc.signalingserver.cases.SignalHandler;
import javax.inject.Inject;
import java.util.Map; | package org.nextrtc.signalingserver.domain.resolver;
public class ManualSignalResolver extends AbstractSignalResolver {
@Inject | // Path: src/main/java/org/nextrtc/signalingserver/cases/SignalHandler.java
// public interface SignalHandler {
// void execute(InternalMessage message);
// }
// Path: src/main/java/org/nextrtc/signalingserver/domain/resolver/ManualSignalResolver.java
import org.nextrtc.signalingserver.cases.SignalHandler;
import javax.inject.Inject;
import java.util.Map;
package org.nextrtc.signalingserver.domain.resolver;
public class ManualSignalResolver extends AbstractSignalResolver {
@Inject | public ManualSignalResolver(Map<String, SignalHandler> handlers) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/repository/Conversations.java | // Path: src/main/java/org/nextrtc/signalingserver/domain/Conversation.java
// @Getter
// @Component
// @Scope("prototype")
// public abstract class Conversation implements NextRTCConversation {
// protected static final ExecutorService parallel = Executors.newCachedThreadPool();
// protected final String id;
//
// private LeftConversation leftConversation;
// protected MessageSender messageSender;
//
// public Conversation(String id) {
// this.id = id;
// }
//
// public Conversation(String id,
// LeftConversation leftConversation,
// MessageSender messageSender) {
// this.id = id;
// this.leftConversation = leftConversation;
// this.messageSender = messageSender;
// }
//
// public abstract void join(Member sender);
//
// public synchronized void left(Member sender) {
// if (remove(sender) && isWithoutMember()) {
// leftConversation.destroy(this, sender);
// }
// }
//
// protected abstract boolean remove(Member leaving);
//
// protected void assignSenderToConversation(Member sender) {
// sender.assign(this);
// }
//
// public abstract boolean isWithoutMember();
//
// public abstract boolean has(Member from);
//
// public abstract void exchangeSignals(InternalMessage message);
//
// protected void sendJoinedToConversation(Member sender, String id) {
// messageSender.send(InternalMessage.create()//
// .to(sender)//
// .content(id)//
// .signal(Signal.JOINED)//
// .build());
// }
//
// protected void sendJoinedFrom(Member sender, Member member) {
// messageSender.send(InternalMessage.create()//
// .from(sender)//
// .to(member)//
// .signal(Signal.NEW_JOINED)//
// .content(sender.getId())
// .build());
// }
//
// protected void sendLeftMessage(Member leaving, Member recipient) {
// messageSender.send(InternalMessage.create()//
// .from(leaving)//
// .to(recipient)//
// .signal(Signal.LEFT)//
// .build());
// }
//
// public abstract void broadcast(Member from, InternalMessage message);
//
// @Inject
// public void setLeftConversation(LeftConversation leftConversation) {
// this.leftConversation = leftConversation;
// }
//
// @Inject
// public void setMessageSender(MessageSender messageSender) {
// this.messageSender = messageSender;
// }
//
// @Override
// public String toString() {
// return this.getClass().getSimpleName() + ": " + id;
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
| import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.domain.Conversation;
import org.nextrtc.signalingserver.domain.Member;
import org.springframework.stereotype.Repository;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.nextrtc.signalingserver.exception.Exceptions.CONVERSATION_NAME_OCCUPIED; | package org.nextrtc.signalingserver.repository;
@Slf4j
@Repository
public class Conversations implements ConversationRepository {
| // Path: src/main/java/org/nextrtc/signalingserver/domain/Conversation.java
// @Getter
// @Component
// @Scope("prototype")
// public abstract class Conversation implements NextRTCConversation {
// protected static final ExecutorService parallel = Executors.newCachedThreadPool();
// protected final String id;
//
// private LeftConversation leftConversation;
// protected MessageSender messageSender;
//
// public Conversation(String id) {
// this.id = id;
// }
//
// public Conversation(String id,
// LeftConversation leftConversation,
// MessageSender messageSender) {
// this.id = id;
// this.leftConversation = leftConversation;
// this.messageSender = messageSender;
// }
//
// public abstract void join(Member sender);
//
// public synchronized void left(Member sender) {
// if (remove(sender) && isWithoutMember()) {
// leftConversation.destroy(this, sender);
// }
// }
//
// protected abstract boolean remove(Member leaving);
//
// protected void assignSenderToConversation(Member sender) {
// sender.assign(this);
// }
//
// public abstract boolean isWithoutMember();
//
// public abstract boolean has(Member from);
//
// public abstract void exchangeSignals(InternalMessage message);
//
// protected void sendJoinedToConversation(Member sender, String id) {
// messageSender.send(InternalMessage.create()//
// .to(sender)//
// .content(id)//
// .signal(Signal.JOINED)//
// .build());
// }
//
// protected void sendJoinedFrom(Member sender, Member member) {
// messageSender.send(InternalMessage.create()//
// .from(sender)//
// .to(member)//
// .signal(Signal.NEW_JOINED)//
// .content(sender.getId())
// .build());
// }
//
// protected void sendLeftMessage(Member leaving, Member recipient) {
// messageSender.send(InternalMessage.create()//
// .from(leaving)//
// .to(recipient)//
// .signal(Signal.LEFT)//
// .build());
// }
//
// public abstract void broadcast(Member from, InternalMessage message);
//
// @Inject
// public void setLeftConversation(LeftConversation leftConversation) {
// this.leftConversation = leftConversation;
// }
//
// @Inject
// public void setMessageSender(MessageSender messageSender) {
// this.messageSender = messageSender;
// }
//
// @Override
// public String toString() {
// return this.getClass().getSimpleName() + ": " + id;
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
// Path: src/main/java/org/nextrtc/signalingserver/repository/Conversations.java
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.domain.Conversation;
import org.nextrtc.signalingserver.domain.Member;
import org.springframework.stereotype.Repository;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.nextrtc.signalingserver.exception.Exceptions.CONVERSATION_NAME_OCCUPIED;
package org.nextrtc.signalingserver.repository;
@Slf4j
@Repository
public class Conversations implements ConversationRepository {
| private Map<String, Conversation> conversations = Maps.newConcurrentMap(); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/repository/Conversations.java | // Path: src/main/java/org/nextrtc/signalingserver/domain/Conversation.java
// @Getter
// @Component
// @Scope("prototype")
// public abstract class Conversation implements NextRTCConversation {
// protected static final ExecutorService parallel = Executors.newCachedThreadPool();
// protected final String id;
//
// private LeftConversation leftConversation;
// protected MessageSender messageSender;
//
// public Conversation(String id) {
// this.id = id;
// }
//
// public Conversation(String id,
// LeftConversation leftConversation,
// MessageSender messageSender) {
// this.id = id;
// this.leftConversation = leftConversation;
// this.messageSender = messageSender;
// }
//
// public abstract void join(Member sender);
//
// public synchronized void left(Member sender) {
// if (remove(sender) && isWithoutMember()) {
// leftConversation.destroy(this, sender);
// }
// }
//
// protected abstract boolean remove(Member leaving);
//
// protected void assignSenderToConversation(Member sender) {
// sender.assign(this);
// }
//
// public abstract boolean isWithoutMember();
//
// public abstract boolean has(Member from);
//
// public abstract void exchangeSignals(InternalMessage message);
//
// protected void sendJoinedToConversation(Member sender, String id) {
// messageSender.send(InternalMessage.create()//
// .to(sender)//
// .content(id)//
// .signal(Signal.JOINED)//
// .build());
// }
//
// protected void sendJoinedFrom(Member sender, Member member) {
// messageSender.send(InternalMessage.create()//
// .from(sender)//
// .to(member)//
// .signal(Signal.NEW_JOINED)//
// .content(sender.getId())
// .build());
// }
//
// protected void sendLeftMessage(Member leaving, Member recipient) {
// messageSender.send(InternalMessage.create()//
// .from(leaving)//
// .to(recipient)//
// .signal(Signal.LEFT)//
// .build());
// }
//
// public abstract void broadcast(Member from, InternalMessage message);
//
// @Inject
// public void setLeftConversation(LeftConversation leftConversation) {
// this.leftConversation = leftConversation;
// }
//
// @Inject
// public void setMessageSender(MessageSender messageSender) {
// this.messageSender = messageSender;
// }
//
// @Override
// public String toString() {
// return this.getClass().getSimpleName() + ": " + id;
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
| import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.domain.Conversation;
import org.nextrtc.signalingserver.domain.Member;
import org.springframework.stereotype.Repository;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.nextrtc.signalingserver.exception.Exceptions.CONVERSATION_NAME_OCCUPIED; | package org.nextrtc.signalingserver.repository;
@Slf4j
@Repository
public class Conversations implements ConversationRepository {
private Map<String, Conversation> conversations = Maps.newConcurrentMap();
@Override
public Optional<Conversation> findBy(String id) {
if (isEmpty(id)) {
return Optional.empty();
}
return Optional.ofNullable(conversations.get(id));
}
@Override | // Path: src/main/java/org/nextrtc/signalingserver/domain/Conversation.java
// @Getter
// @Component
// @Scope("prototype")
// public abstract class Conversation implements NextRTCConversation {
// protected static final ExecutorService parallel = Executors.newCachedThreadPool();
// protected final String id;
//
// private LeftConversation leftConversation;
// protected MessageSender messageSender;
//
// public Conversation(String id) {
// this.id = id;
// }
//
// public Conversation(String id,
// LeftConversation leftConversation,
// MessageSender messageSender) {
// this.id = id;
// this.leftConversation = leftConversation;
// this.messageSender = messageSender;
// }
//
// public abstract void join(Member sender);
//
// public synchronized void left(Member sender) {
// if (remove(sender) && isWithoutMember()) {
// leftConversation.destroy(this, sender);
// }
// }
//
// protected abstract boolean remove(Member leaving);
//
// protected void assignSenderToConversation(Member sender) {
// sender.assign(this);
// }
//
// public abstract boolean isWithoutMember();
//
// public abstract boolean has(Member from);
//
// public abstract void exchangeSignals(InternalMessage message);
//
// protected void sendJoinedToConversation(Member sender, String id) {
// messageSender.send(InternalMessage.create()//
// .to(sender)//
// .content(id)//
// .signal(Signal.JOINED)//
// .build());
// }
//
// protected void sendJoinedFrom(Member sender, Member member) {
// messageSender.send(InternalMessage.create()//
// .from(sender)//
// .to(member)//
// .signal(Signal.NEW_JOINED)//
// .content(sender.getId())
// .build());
// }
//
// protected void sendLeftMessage(Member leaving, Member recipient) {
// messageSender.send(InternalMessage.create()//
// .from(leaving)//
// .to(recipient)//
// .signal(Signal.LEFT)//
// .build());
// }
//
// public abstract void broadcast(Member from, InternalMessage message);
//
// @Inject
// public void setLeftConversation(LeftConversation leftConversation) {
// this.leftConversation = leftConversation;
// }
//
// @Inject
// public void setMessageSender(MessageSender messageSender) {
// this.messageSender = messageSender;
// }
//
// @Override
// public String toString() {
// return this.getClass().getSimpleName() + ": " + id;
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/Member.java
// @Getter
// @Component
// @Scope("prototype")
// public class Member implements NextRTCMember {
//
// private String id;
// private Connection connection;
// private Conversation conversation;
//
// private NextRTCEventBus eventBus;
//
// private ScheduledFuture<?> ping;
//
// public Member(Connection connection, ScheduledFuture<?> ping) {
// this.id = connection.getId();
// this.connection = connection;
// this.ping = ping;
// }
//
// public Optional<Conversation> getConversation() {
// return Optional.ofNullable(conversation);
// }
//
// public void markLeft() {
// ping.cancel(true);
// }
//
// void assign(Conversation conversation) {
// this.conversation = conversation;
// eventBus.post(MEMBER_JOINED.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// }
//
// public void unassignConversation(Conversation conversation) {
// eventBus.post(MEMBER_LEFT.basedOn(
// builder()
// .conversation(conversation)
// .from(this)));
// this.conversation = null;
// }
//
// public boolean hasSameConversation(Member to) {
// return to != null && conversation.equals(to.conversation);
// }
//
// @Inject
// public void setEventBus(NextRTCEventBus eventBus) {
// this.eventBus = eventBus;
// }
//
// @Override
// public String toString() {
// return String.format("%s", id);
// }
//
// public synchronized Connection getConnection() {
// return connection;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Member)) {
// return false;
// }
// Member m = (Member) o;
// return new EqualsBuilder()//
// .append(m.id, id)//
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder()//
// .append(id)//
// .build();
// }
// }
// Path: src/main/java/org/nextrtc/signalingserver/repository/Conversations.java
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.nextrtc.signalingserver.domain.Conversation;
import org.nextrtc.signalingserver.domain.Member;
import org.springframework.stereotype.Repository;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.nextrtc.signalingserver.exception.Exceptions.CONVERSATION_NAME_OCCUPIED;
package org.nextrtc.signalingserver.repository;
@Slf4j
@Repository
public class Conversations implements ConversationRepository {
private Map<String, Conversation> conversations = Maps.newConcurrentMap();
@Override
public Optional<Conversation> findBy(String id) {
if (isEmpty(id)) {
return Optional.empty();
}
return Optional.ofNullable(conversations.get(id));
}
@Override | public Optional<Conversation> findBy(Member from) { |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java | // Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
| import org.nextrtc.signalingserver.domain.Connection; | package org.nextrtc.signalingserver.api.dto;
public interface NextRTCMember {
default String getId() {
return getConnection().getId();
}
| // Path: src/main/java/org/nextrtc/signalingserver/domain/Connection.java
// public interface Connection {
// String getId();
//
// boolean isOpen();
//
// void sendObject(Object object);
//
// void close() throws IOException;
// }
// Path: src/main/java/org/nextrtc/signalingserver/api/dto/NextRTCMember.java
import org.nextrtc.signalingserver.domain.Connection;
package org.nextrtc.signalingserver.api.dto;
public interface NextRTCMember {
default String getId() {
return getConnection().getId();
}
| Connection getConnection(); |
mslosarz/nextrtc-signaling-server | src/main/java/org/nextrtc/signalingserver/modules/NextRTCMedia.java | // Path: src/main/java/org/nextrtc/signalingserver/cases/ExchangeSignalsBetweenMembers.java
// @Component
// @Scope("prototype")
// public class ExchangeSignalsBetweenMembers {
//
// private RTCConnections connections;
// private ConnectionContextFactory factory;
//
// @Inject
// public ExchangeSignalsBetweenMembers(RTCConnections connections, ConnectionContextFactory factory) {
// this.connections = connections;
// this.factory = factory;
// }
//
// public synchronized void begin(Member from, Member to) {
// connections.put(from, to, factory.create(from, to));
// connections.get(from, to).ifPresent(ConnectionContext::begin);
// }
//
// public synchronized void execute(InternalMessage message) {
// connections.get(message.getFrom(), message.getTo()).ifPresent(context -> context.process(message));
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/DefaultMessageSender.java
// @Component
// @Scope("singleton")
// @Slf4j
// public class DefaultMessageSender implements MessageSender {
//
// private MemberRepository members;
//
// @Inject
// public DefaultMessageSender(MemberRepository members) {
// this.members = members;
// }
//
// @Override
// public void send(InternalMessage message) {
// send(message, 3);
// }
//
// private void send(InternalMessage message, int retry) {
// if (message.getSignal() != Signal.PING) {
// log.debug("Outgoing: " + message.transformToExternalMessage());
// }
// if (message.getSignal() == Signal.ERROR) {
// tryToSendErrorMessage(message);
// return;
// }
// Member destination = message.getTo();
// if (destination == null || !destination.getConnection().isOpen()) {
// log.warn("Destination member is not set or session is closed! Message will not be send: " + message.transformToExternalMessage());
// return;
// }
// members.findBy(destination.getId()).ifPresent(member ->
// lockAndRun(message, member, retry)
// );
// }
//
// private void tryToSendErrorMessage(InternalMessage message) {
// try {
// Connection connection = message.getTo().getConnection();
// synchronized (connection) {
// connection.sendObject(message.transformToExternalMessage());
// }
// } catch (Exception e) {
// throw new RuntimeException("Unable to send message: " + message.transformToExternalMessage(), e);
// }
// }
//
// private void lockAndRun(InternalMessage message, Member destination, int retry) {
// try {
// Connection connection = destination.getConnection();
// synchronized (destination) {
// connection.sendObject(message.transformToExternalMessage());
// }
// } catch (Exception e) {
// if (retry >= 0) {
// log.warn("Retrying... " + message.transformToExternalMessage());
// send(message, --retry);
// }
// log.error("Unable to send message: " + message.transformToExternalMessage() + " error during sending!");
// throw new RuntimeException("Unable to send message: " + message.transformToExternalMessage(), e);
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/RTCConnections.java
// @Component
// @Scope("singleton")
// public class RTCConnections implements Closeable{
// private static Table<Member, Member, ConnectionContext> connections = HashBasedTable.create();
//
// private ScheduledExecutorService scheduler;
// private NextRTCProperties properties;
//
// @Inject
// public RTCConnections(ScheduledExecutorService scheduler, NextRTCProperties properties) {
// this.scheduler = scheduler;
// this.properties = properties;
// }
//
// @PostConstruct
// void cleanOldConnections() {
// scheduler.scheduleWithFixedDelay(this::removeOldConnections,
// properties.getMaxConnectionSetupTime(),
// properties.getMaxConnectionSetupTime(),
// TimeUnit.SECONDS);
// }
//
// void removeOldConnections() {
// List<ConnectionContext> oldConnections = connections.values().stream()
// .filter(context -> !context.isCurrent())
// .collect(Collectors.toList());
// oldConnections.forEach(c -> connections.remove(c.getMaster(), c.getSlave()));
// }
//
// public void put(Member from, Member to, ConnectionContext ctx) {
// connections.put(from, to, ctx);
// connections.put(to, from, ctx);
// }
//
// public Optional<ConnectionContext> get(Member from, Member to) {
// return Optional.ofNullable(connections.get(from, to));
// }
//
//
// @Override
// public void close() throws IOException {
// connections.clear();
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConnectionContextFactory.java
// public interface ConnectionContextFactory {
// ConnectionContext create(Member from, Member to);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
| import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.domain.DefaultMessageSender;
import org.nextrtc.signalingserver.domain.RTCConnections;
import org.nextrtc.signalingserver.factory.ConnectionContextFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import javax.inject.Singleton;
import java.util.concurrent.ScheduledExecutorService; | package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCMedia {
@Provides | // Path: src/main/java/org/nextrtc/signalingserver/cases/ExchangeSignalsBetweenMembers.java
// @Component
// @Scope("prototype")
// public class ExchangeSignalsBetweenMembers {
//
// private RTCConnections connections;
// private ConnectionContextFactory factory;
//
// @Inject
// public ExchangeSignalsBetweenMembers(RTCConnections connections, ConnectionContextFactory factory) {
// this.connections = connections;
// this.factory = factory;
// }
//
// public synchronized void begin(Member from, Member to) {
// connections.put(from, to, factory.create(from, to));
// connections.get(from, to).ifPresent(ConnectionContext::begin);
// }
//
// public synchronized void execute(InternalMessage message) {
// connections.get(message.getFrom(), message.getTo()).ifPresent(context -> context.process(message));
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/DefaultMessageSender.java
// @Component
// @Scope("singleton")
// @Slf4j
// public class DefaultMessageSender implements MessageSender {
//
// private MemberRepository members;
//
// @Inject
// public DefaultMessageSender(MemberRepository members) {
// this.members = members;
// }
//
// @Override
// public void send(InternalMessage message) {
// send(message, 3);
// }
//
// private void send(InternalMessage message, int retry) {
// if (message.getSignal() != Signal.PING) {
// log.debug("Outgoing: " + message.transformToExternalMessage());
// }
// if (message.getSignal() == Signal.ERROR) {
// tryToSendErrorMessage(message);
// return;
// }
// Member destination = message.getTo();
// if (destination == null || !destination.getConnection().isOpen()) {
// log.warn("Destination member is not set or session is closed! Message will not be send: " + message.transformToExternalMessage());
// return;
// }
// members.findBy(destination.getId()).ifPresent(member ->
// lockAndRun(message, member, retry)
// );
// }
//
// private void tryToSendErrorMessage(InternalMessage message) {
// try {
// Connection connection = message.getTo().getConnection();
// synchronized (connection) {
// connection.sendObject(message.transformToExternalMessage());
// }
// } catch (Exception e) {
// throw new RuntimeException("Unable to send message: " + message.transformToExternalMessage(), e);
// }
// }
//
// private void lockAndRun(InternalMessage message, Member destination, int retry) {
// try {
// Connection connection = destination.getConnection();
// synchronized (destination) {
// connection.sendObject(message.transformToExternalMessage());
// }
// } catch (Exception e) {
// if (retry >= 0) {
// log.warn("Retrying... " + message.transformToExternalMessage());
// send(message, --retry);
// }
// log.error("Unable to send message: " + message.transformToExternalMessage() + " error during sending!");
// throw new RuntimeException("Unable to send message: " + message.transformToExternalMessage(), e);
// }
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/domain/RTCConnections.java
// @Component
// @Scope("singleton")
// public class RTCConnections implements Closeable{
// private static Table<Member, Member, ConnectionContext> connections = HashBasedTable.create();
//
// private ScheduledExecutorService scheduler;
// private NextRTCProperties properties;
//
// @Inject
// public RTCConnections(ScheduledExecutorService scheduler, NextRTCProperties properties) {
// this.scheduler = scheduler;
// this.properties = properties;
// }
//
// @PostConstruct
// void cleanOldConnections() {
// scheduler.scheduleWithFixedDelay(this::removeOldConnections,
// properties.getMaxConnectionSetupTime(),
// properties.getMaxConnectionSetupTime(),
// TimeUnit.SECONDS);
// }
//
// void removeOldConnections() {
// List<ConnectionContext> oldConnections = connections.values().stream()
// .filter(context -> !context.isCurrent())
// .collect(Collectors.toList());
// oldConnections.forEach(c -> connections.remove(c.getMaster(), c.getSlave()));
// }
//
// public void put(Member from, Member to, ConnectionContext ctx) {
// connections.put(from, to, ctx);
// connections.put(to, from, ctx);
// }
//
// public Optional<ConnectionContext> get(Member from, Member to) {
// return Optional.ofNullable(connections.get(from, to));
// }
//
//
// @Override
// public void close() throws IOException {
// connections.clear();
// }
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/factory/ConnectionContextFactory.java
// public interface ConnectionContextFactory {
// ConnectionContext create(Member from, Member to);
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/property/NextRTCProperties.java
// public interface NextRTCProperties {
// int getMaxConnectionSetupTime();
//
// int getPingPeriod();
//
// int getSchedulerPoolSize();
//
// boolean isJoinOnlyToExisting();
//
// String getDefaultConversationType();
// }
//
// Path: src/main/java/org/nextrtc/signalingserver/repository/MemberRepository.java
// public interface MemberRepository extends Closeable{
// Collection<String> getAllIds();
//
// Optional<Member> findBy(String id);
//
// Member register(Member member);
//
// void unregister(String id);
//
// }
// Path: src/main/java/org/nextrtc/signalingserver/modules/NextRTCMedia.java
import dagger.Module;
import dagger.Provides;
import org.nextrtc.signalingserver.cases.ExchangeSignalsBetweenMembers;
import org.nextrtc.signalingserver.domain.DefaultMessageSender;
import org.nextrtc.signalingserver.domain.RTCConnections;
import org.nextrtc.signalingserver.factory.ConnectionContextFactory;
import org.nextrtc.signalingserver.property.NextRTCProperties;
import org.nextrtc.signalingserver.repository.MemberRepository;
import javax.inject.Singleton;
import java.util.concurrent.ScheduledExecutorService;
package org.nextrtc.signalingserver.modules;
@Module
public abstract class NextRTCMedia {
@Provides | static DefaultMessageSender defaultMessageSender(MemberRepository repo) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.