如何使用SentiWordNet获取String或形容词的语义方向

我正在做一个关于情绪分析的项目。 我需要字符串或形容词的语义方向,所以我建议使用Stackoverflow“如何使用SentiWordNet”的参考文章中的SentiWordNet_3.0.0。我运行了代码,但每次得到以下输出。 java.lang.ArrayIndexOutOfBoundsException: 2 at qtag.SWN3.(SWN3.java:29) at qtag.SWN3.main(SWN3.java:105) 0.0 我已经使用不同的字符串作为输入运行代码,但结果是相同的。 我已经删除了SentiWordNet_3.0.0_20130122.txt文件的第一部分或垃圾部分。我的代码有什么问题。我该怎么办呢? 请帮帮我。 谢谢。 这是我的代码: import java.io.BufferedReader; import java.io.FileReader; import java.util.HashMap; import java.util.Iterator; import java.util.Set; import java.util.Vector; public class SWN3 { private String pathToSWN = “C:/Users/Monalisa/Desktop/SentiWordNet_3.0.0/home/swn/www/admin/dump/SentiWordNet_3.0.0_20130122.txt”; private HashMap_dict; public SWN3(){ _dict = new HashMap(); HashMap<String, Vector> _temp = new HashMap<String, Vector>(); try{ BufferedReader csv = new […]

如何获得过滤后的模型?

我正在使用JTables显示用户可以过滤的信息,如果用户在过滤后保存,我想将过滤后的表保存到文本文件中以保持持久性(意味着任何过滤掉的内容都不会保存到文本文件中)。 对于过滤我只是按照本教程的过滤部分: http : //download.oracle.com/javase/tutorial/uiswing/components/table.html#sorting并且它工作正常,但我不确定是否有任何方法我可以获得当前显示的模型,而不是包含尚未过滤掉的所有内容的基础模型。 有什么方法可以用我过滤的方式来做到这一点吗? 谢谢!

如何从ttf文件中获取汉字笔画顺序?

我发现getGlyphOutline()可以显示JAVA API的字体输出行。 我还没有发现任何用于显示中国笔画顺序的API。 但这是真的: .ttf包含笔画顺序。 我只是不知道如何通过JAVA获得它。 可能是一些我忘记的重要API? shape = gv.getGlyphOutline(i, 200, 200); ((Graphics2D) g).draw(shape); 现在,我找到了PathIterator Shape shape = gv.getGlyphOutline(0, 200, 200); PathIterator pi = shape.getPathIterator(new AffineTransform()); double[] coords = new double[6]; int count = 0; while (!pi.isDone()) { int kind = pi.currentSegment(coords); int[] path = new int[4]; switch (kind) { case PathIterator.SEG_MOVETO: System.out.println(“SEG_MOVETO”); break; case […]

在外部项目中强制执行自定义规则

我有一个Parent maven项目和该项目中的4个模块: 现在我想提出一些自定义规则,说明不存在以字符串“master-”开头的项目版本或依赖版本。 此规则适用于依赖于eBill软件的所有外部项目。 所以我创建了一个名为customRule的新模块,其父级也是eBill Software。 我遵循写一个自定义规则 ,我的规则类在新模块中。 模块customRule中CustomRule.java的相关部分: MavenProject project = (MavenProject) helper.evaluate( “${project}” ); Set artifacts = project.getArtifacts(); boolean containsInvalid = artifacts.stream() .filter(item -> item.getVersion() .startsWith(“master-“)) .anyMatch(item -> true); if(containsInvalid) { this.shouldIfail = true; } customRule模块pom.xml的相关部分: org.apache.maven.plugins maven-enforcer-plugin 1.4 enforce-no-master-versions enforce false 现在我想在父模块eBill软件中访问此自定义规则: 那么我应该在其pom.xml和外部项目的pom.xml中输入什么才能获得适用于依赖于eBill软件的所有外部项目的自定义规则。

Java Rest API在JAX-RS中调用另一个Rest而不等待响应

我有一个案例要在我的项目中实现.Below是一个必须实现的示例rest服务 @GET @Path(“/test/{id}”) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public String getData(@PathParam(“id”) String id) { //Some processing to get value of String String result = doSomeProcessing(); //I want to return this result to GUI and call one more rest api // and end this process without waiting for response from second //call new Thread(){ //call second rest api }.start(); […]

Vaadin:如何使validation器只接受数字和一位小数

我正在尝试validation文本字段只有数字和一个小数,但小数值会导致validation器关闭: TextField tf = new TextField(); tf.addValidator(new RegexpValidator(“^\\d+$”, facilityId.getCaption() + “Only numbers and one decimal allowed.”)); 所以我得到了数字,但我如何告诉validation者“。” 没关系? 注意: Add-Ons不是一个选项。

解析存储为字符串的浮点数应抛出exception

我有一个存储数字的字符串。 现在我想解析该字符串并获得浮点数。 import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be “Main” only if the class is public. */ class Ideone { public static void main (String[] args) throws java.lang.Exception { try { System.out.println(Integer.parseInt(” 2 “)); } catch(NumberFormatException e) { System.out.println(“Exception caught”); } System.out.println(Float.parseFloat(” 2.4 “)); } } 现在在上面的代码中,如果你运行它将成功。 我的问题是为什么在整数的情况下尾随空格抛出一个NumberFormatException而解析一个浮点数不会抛出一个? […]

使用Spring + Netty的UDP服务器

我正在尝试使用Netty设置一个简单的UDP服务器,遵循此处的示例,但使用Spring进行连接依赖。 我的Spring配置类: @Configuration @ComponentScan(“com.example.netty”) public class SpringConfig { @Value(“${netty.nThreads}”) private int nThreads; @Autowired private MyHandlerA myHandlerA; @Autowired private MyHandlerB myHandlerB; @Bean(name = “bootstrap”) public Bootstrap bootstrap() { Bootstrap b = new Bootstrap(); b.group(group()) .channel(NioDatagramChannel.class) .handler(new ChannelInitializer() { @Override protected void initChannel(DatagramChannel ch) throws Exception { ch.pipeline().addLast(myHandlerA, myHandlerB); } }); return b; } @Bean(name = “group”, […]

如何在JTable中隐藏网格线

我试图隐藏JTable的网格线但没有结果。 即使尝试更改网格线的颜色也不起作用。 这是我的代码: // build the table tableView = new JTable(ttm); //Specifify the selection Listener and model listSelectionModel = tableView.getSelectionModel(); listSelectionModel.addListSelectionListener(new SharedListSelectionHandler(tableView)); tableView.setSelectionModel(listSelectionModel); //Add a mouse listener to our table and implement double click event tableView.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ //If double click in a message show the Message Details window if (e.getClickCount() == […]

如何使Java Regex匹配除指定模式之外的所有内容

我试图在整个字符串中匹配除垃圾值之外的所有内容。我尝试使用的模式是: ^.*(?!\w|\s|-|\.|[@:,]).*$ 我一直在regexPlanet上测试模式,这似乎与整个字符串匹配。我使用的输入字符串是: Vamsi///#k03@g!!!l.com 123**5 我怎样才能让它只匹配除模式之外的所有内容,我想替换任何与空白空间或我选择的特殊字符匹配的字符串。