-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from OpenReqEU/DeveloperAntoni
TFIDF feature extraction branch
- Loading branch information
Showing
19 changed files
with
2,062 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Linguistic | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>linguistic</groupId> | ||
<artifactId>rake</artifactId> | ||
<version>1.0</version> | ||
<description>POM was created from install:install-file</description> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/java/com/gessi/dependency_detection/WordEmbedding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.gessi.dependency_detection; | ||
|
||
import de.jungblut.glove.GloveRandomAccessReader; | ||
import de.jungblut.glove.impl.GloveBinaryRandomAccessReader; | ||
import de.jungblut.math.DoubleVector; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Paths; | ||
|
||
import static java.lang.Math.sqrt; | ||
|
||
public class WordEmbedding { | ||
|
||
GloveRandomAccessReader db = new GloveBinaryRandomAccessReader(Paths.get("gloveModel")); | ||
|
||
public WordEmbedding() throws IOException { | ||
} | ||
|
||
|
||
/** | ||
* Computes the cosine similarity between two words, if these vectors exist in the underlying Glove model | ||
* @param a first word | ||
* @param b second word | ||
* @return The cosine similarity between the two words | ||
*/ | ||
public Double computeSimilarity(String a, String b) throws IOException { | ||
DoubleVector help1 = null, help2 = null; | ||
if (db.contains(a)) help1 = db.get(a); | ||
if (db.contains(b)) help2 = db.get(b); | ||
if (help1 != null && help2 != null) { | ||
return cosineSimilarity(help1,help2); | ||
} else return -1.0; | ||
} | ||
|
||
|
||
private Double cosineSimilarity(DoubleVector help1, DoubleVector help2) { | ||
double[] one=help1.toArray(); | ||
double[] two=help2.toArray(); | ||
int length=one.length; | ||
Double sum = 0.0; | ||
if (two.length>length) length=two.length; | ||
for (int i=0;i<length;++i) { | ||
sum += one[i] * two[i]; | ||
} | ||
return sum / (norm(one) * norm(two)); | ||
} | ||
private Double norm(double[] array) { | ||
Double tot = 0.0; | ||
for (Double d : array) { | ||
tot += d * d; | ||
} | ||
return sqrt(tot); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/com/gessi/dependency_detection/domain/KeywordTool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.gessi.dependency_detection.domain; | ||
|
||
public enum KeywordTool { | ||
|
||
RULE_BASED, | ||
TFIDF_BASED | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/gessi/dependency_detection/domain/Requirement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.gessi.dependency_detection.domain; | ||
|
||
public class Requirement { | ||
String description; | ||
String id; | ||
|
||
public Requirement(String s, String s1) { | ||
description=s1; | ||
id=s; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
} |
Oops, something went wrong.