小编Dan*_*iel的帖子

SBT 的 Java 代码格式化程序

Java项目有没有用于Java代码格式化的sbt插件?我做了一些搜索,但似乎所有基于 sbt 的格式化程序都适用于 Scala 的语法。

java sbt

5
推荐指数
1
解决办法
550
查看次数

模糊.substring文本匹配函数

我正在寻找一种模糊substring功能的方法.我是什么意思:

  • 给出了两个字符串.
  • 一个通常比另一个长.让我们称之为"短"和"长"
  • 我们想得分"长"中出现了多少"短".
  • 我们想要考虑邻近度和奥得河.就像"短"的元素出现在"长"中一样,它们最好以相同的顺序出现并且彼此接近.

例1:

  • 简短:"杂草被毁"
  • 长期:"用细菌基因改造的作物使植物对除草剂具有抗性可以在杂草被破坏的情况下生长,并且能够抵抗破坏性昆虫的基因工程作物减少了对化学杀虫剂的需求."

这是完全匹配,应该得分1.0.

例2:

  • 简短:"杂草将被摧毁"
  • 长:与上面相同.

这是模糊匹配,因为"weed"和"destroyed"出现在文本中,但没有"将会".它应该得到一个高分(比如0.8).

例3:

如果我们将"短"设置为"被破坏将是杂草",虽然"破坏"和"杂草"都出现在原始文本中,但分数应该非常低,因为它们的顺序已经改变.

对此有何建议实施?

最后一点是,没有独特的方法来进行评分.但我正在寻找AN算法.可以根据需要和要求调整该算法的参数.

algorithm nlp substring

5
推荐指数
1
解决办法
280
查看次数

StanfordCoreNLP:为什么 SemanticGraph 有多个根(例如依赖解析)

在用于依赖解析的 SemanticGraph 类的定义中。

这是变量“roots”作为顶点集合的定义:

private final Collection<IndexedWord> roots;
Run Code Online (Sandbox Code Playgroud)

我的问题是为什么要收藏?在什么情况下我们需要多个顶点作为根?

https://github.com/stanfordnlp/CoreNLP/blob/master/src/edu/stanford/nlp/semgraph/SemanticGraph.java

nlp stanford-nlp

4
推荐指数
1
解决办法
293
查看次数

'URLEncoder.encode`的正确编码

我正在尝试标准化我的网址中的邮件,而我正在使用URLEncoder.encode.我得到的问题是,输出似乎不是一个有效的网址.例如

val text = Some("test question (a) x (b) y").get
val query = "http://localhost:8080/ask?text=" + text
println(query)
val queryEnc = URLEncoder.encode(query, "UTF-8")
println(queryEnc)
Run Code Online (Sandbox Code Playgroud)

输出:

http://localhost:8080/ask?text=test question (a) x (b) y
http%3A%2F%2Flocalhost%3A8080%2Fask%3Ftext%3Dtest+question+%28a%29+x+%28b%29+y
Run Code Online (Sandbox Code Playgroud)

输出是否是有效的URL?(它看起来没有效果,因为我机器上的Chrome和Safari无法识别它).

java scala urlencode url-encoding

4
推荐指数
1
解决办法
5179
查看次数

使用eval()将字符串转换为JavaScript中的JSON对象

我正在将以下JSON变量转换为字符串.回到JSON时,我收到一个错误(在ReactJS中,虽然它不重要).

var questionGlobal = {
  "questionCons": [{
    "string": "In",
    "alignment": 2
  }, {
    "string": "New York State",
    "alignment": 1
  }, {
    "string": "the",
    "alignment": -1
  }, {
    "string": "shortest",
    "alignment": -1
  }, {
    "string": "period",
    "alignment": 0
  }, {
    "string": "of",
    "alignment": 2
  }, {
    "string": "daylight",
    "alignment": 0
  }, {
    "string": "occurs",
    "alignment": 2
  }, {
    "string": "during",
    "alignment": 1
  }, {
    "string": "which",
    "alignment": 0
  }, {
    "string": "month",
    "alignment": 0
  }],
  "options": [{
    "string": "January",
    "alignment": 1 …
Run Code Online (Sandbox Code Playgroud)

javascript json reactjs

4
推荐指数
1
解决办法
2万
查看次数

Javadoc:如何修复:"错误的HTML实体"错误

我收到此错误:

[ERROR] /Users/daniel/ideaProjects/lbjava/lbjava/src/main/java/edu/illinois/cs/cogcomp/lbjava/learn/NaiveBayes.java:638: error: bad HTML entity
[ERROR] * P(e's label && e)
[ERROR] ^
[ERROR] /Users/daniel/ideaProjects/lbjava/lbjava/src/main/java/edu/illinois/cs/cogcomp/lbjava/learn/NaiveBayes.java:638: error: bad HTML entity
[ERROR] * P(e's label && e)
[ERROR] ^
Run Code Online (Sandbox Code Playgroud)

以下是完整评论:

    /**
     * Takes the dot product of this vector with the given vector, using the specified default
     * weight when encountering a feature that is not yet present in this vector. Here, weights
     * are taken as <i>log(feature count / prior count)</i>. The output of this method is
     * related …
Run Code Online (Sandbox Code Playgroud)

javadoc

4
推荐指数
1
解决办法
2567
查看次数

Jenkins:由于位置地址中有一个额外的"%402"字符而导致的失败

我的运行失败,我认为由于位置地址中存在这个可疑字符"%402".当我通过终端检查文件夹名称时,此文件夹名称不存在,而它出现在Jenkins日志中.我想知道有没有类似的经历.

以下是错误日志中的代码段:

Results :

Tests in error: 
  testMultiThreading(edu.illinois.cs.cogcomp.edison.annotators.SimpleGazetteerAnnotatorTest): java.io.FileNotFoundException: /home/mangipu2/.jenkins/workspace/cogcomp-nlp%402/edison/target/classes/testgazetteers/names (No such file or directory)
  testAddView(edu.illinois.cs.cogcomp.edison.annotators.SimpleGazetteerAnnotatorTest): java.io.FileNotFoundException: /home/mangipu2/.jenkins/workspace/cogcomp-nlp%402/edison/target/classes/testgazetteers/names (No such file or directory)
  testSimpleGazetteerAnnotatorString(edu.illinois.cs.cogcomp.edison.annotators.SimpleGazetteerAnnotatorTest): java.io.FileNotFoundException: /home/mangipu2/.jenkins/workspace/cogcomp-nlp%402/edison/target/classes/testgazetteers/names (No such file or directory)
  testNonLazy(edu.illinois.cs.cogcomp.edison.annotators.AnnotatorLazyInitTest): java.io.FileNotFoundException: /home/mangipu2/.jenkins/workspace/cogcomp-nlp%402/edison/target/classes/testgazetteers/names (No such file or directory)
  testLazy(edu.illinois.cs.cogcomp.edison.annotators.AnnotatorLazyInitTest): java.io.FileNotFoundException: /home/mangipu2/.jenkins/workspace/cogcomp-nlp%402/edison/target/classes/testgazetteers/names (No such file or directory)
Run Code Online (Sandbox Code Playgroud)

和完整的错误日志:http://morgoth.cs.illinois.edu:8080/job /cogcomp-nlp/74/console

continuous-integration jenkins

4
推荐指数
1
解决办法
1526
查看次数

WikiData端点中的路径查询?

考虑以下片段

ASK WHERE { wd:Q734774 wdt:P31 wd:Q3918. }
Run Code Online (Sandbox Code Playgroud)

在WikiData中可以正常工作。我想在此代码段中使用一些路径语法。具体来说,我想限制路径中使用“ wdt:P31”的次数。根据准则,这应该是正确的语法:

ASK WHERE { wd:Q734774 wdt:P31{,3} wd:Q3918. }
Run Code Online (Sandbox Code Playgroud)

但这给了我奇怪的错误信息。有任何想法吗?

sparql wikidata wikidata-api

4
推荐指数
1
解决办法
162
查看次数

sbt:模块之间的循环依赖?

是否有可能在多模块项目的模块之间存在循环依赖性?

这是一个例子:

lazy val client = (project in file("client"))
  .dependsOn(service)
  .settings(...)

lazy val service = (project in file("service"))
  .dependsOn(client)
  .settings(...)
Run Code Online (Sandbox Code Playgroud)

我得到一个错误recursive value x needs type,我认为是由于这个递归定义,但不完全确定(可能会有一些其他奇怪的现象导致这种情况).

scala sbt

3
推荐指数
1
解决办法
1239
查看次数

为什么 Play Framework 2.5 不尊重 sbt 中的 JVM 内存设置?

所以我一直在努力使用 Play inside sbt 设置内存设置:

javaOptions ++= Seq("-Xmx11G", "-Xms3G")
Run Code Online (Sandbox Code Playgroud)

但似乎并没有尊重它。

当我打印它时

val mb = 1024*1024

//Getting the runtime reference from system
val runtime = Runtime.getRuntime

println("##### Heap utilization statistics [MB] #####")

//Print used memory
println("Used Memory:" + (runtime.totalMemory() - runtime.freeMemory()) / mb)

//Print free memory
println("Free Memory:" + runtime.freeMemory() / mb)

//Print total available memory
println("Total Memory:" + runtime.totalMemory() / mb)

//Print Maximum available memory
println("Max Memory:" + runtime.maxMemory() / mb)
Run Code Online (Sandbox Code Playgroud)

这是我所看到的:

##### Heap utilization statistics [MB] #####
Used Memory:270 …
Run Code Online (Sandbox Code Playgroud)

scala sbt playframework

3
推荐指数
1
解决办法
1718
查看次数