-
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.
- Loading branch information
0 parents
commit 3a9cee1
Showing
30 changed files
with
3,120 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.ftz filter=lfs diff=lfs merge=lfs -text |
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,153 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
|
||
build-linux: | ||
|
||
runs-on: ubuntu-latest | ||
container: gcc:10-buster | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: 'true' | ||
|
||
- name: Make | ||
run: cd src/main/native && make -j4 | ||
|
||
- name: Upload shared library | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: linux_lib | ||
path: src/main/native/libfasttext.so | ||
|
||
test-linux: | ||
|
||
runs-on: ubuntu-latest | ||
needs: build-linux | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
lfs: 'true' | ||
|
||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '11' | ||
|
||
- name: Download shared library | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: linux_lib | ||
path: src/main/resources/com/diffbot/fasttext | ||
|
||
- name: Test | ||
run: ./gradlew test | ||
|
||
build-macos-x86: | ||
|
||
runs-on: macos-13 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: 'true' | ||
|
||
- name: Make | ||
run: | | ||
cd src/main/native | ||
make -j4 | ||
ls -la | ||
mv libfasttext.so libfasttext-mac-x86_64.so | ||
- name: Upload shared library | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: macos_x86_lib | ||
path: src/main/native/libfasttext-mac-x86_64.so | ||
|
||
|
||
test-macos-x86: | ||
|
||
runs-on: macos-13 | ||
needs: build-macos-x86 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
lfs: 'true' | ||
|
||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '11' | ||
|
||
- name: Download shared library | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: macos_x86_lib | ||
path: src/main/resources/com/diffbot/fasttext | ||
|
||
- name: Test | ||
run: ./gradlew test | ||
|
||
build-macos-arm64: | ||
|
||
runs-on: macos-14 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: 'true' | ||
|
||
- name: Make | ||
run: | | ||
cd src/main/native | ||
clang --version | ||
clang -print-targets | ||
make -j4 CXXFLAGS=' -std=c++11 -mcpu=apple-m1 -fPIC' | ||
ls -la | ||
mv libfasttext.so libfasttext-mac-aarch64.so | ||
- name: Upload shared library | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: macos_arm64_lib | ||
path: src/main/native/libfasttext-mac-aarch64.so | ||
|
||
test-macos-arm64: | ||
|
||
runs-on: macos-14 | ||
needs: build-macos-arm64 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
lfs: 'true' | ||
|
||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '11' | ||
|
||
- name: Download shared library | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: macos_arm64_lib | ||
path: src/main/resources/com/diffbot/fasttext | ||
|
||
- name: Test | ||
run: ./gradlew test |
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,46 @@ | ||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/workspace.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store | ||
|
||
### libraries | ||
*.so |
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,3 @@ | ||
[submodule "src/main/native/fastText"] | ||
path = src/main/native/fastText | ||
url = https://github.com/facebookresearch/fastText.git |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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) 2024 Diffbot Technologies Corp. | ||
|
||
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. |
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,29 @@ | ||
## Introduction | ||
|
||
fastText-jni is a Java wrapper for [fastText](https://github.com/facebookresearch/fastText) inference. | ||
|
||
## Usage | ||
|
||
`implementation group: 'com.diffbot', name: 'fasttext-jni', version: '0.9.2.7'` | ||
|
||
```java | ||
FastTextModel model; | ||
try(InputStream inputStream = this.getClass().getResourceAsStream(MODEL)) { | ||
model = new FastTextModel(inputStream); | ||
} | ||
Prediction prediction = model.predictProba(TEXT); | ||
System.out.println(prediction.label + " : " + prediction.probability); | ||
model.close(); | ||
``` | ||
|
||
## Development | ||
|
||
### Install git lfs | ||
|
||
* Install git lfs | ||
* Mac OSX: `brew install git-lfs` | ||
* Archlinux: `pacman -S git-lfs` | ||
* Other: https://github.com/git-lfs/git-lfs/wiki/Installation | ||
* `git lfs install` in the git repo | ||
|
||
`git submodule update --init` |
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,29 @@ | ||
plugins { | ||
id 'java-library' | ||
id 'maven-publish' | ||
} | ||
|
||
group = 'com.diffbot' | ||
version = '0.9.2.7' | ||
|
||
sourceCompatibility = 11 | ||
targetCompatibility = 11 | ||
|
||
java { | ||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation platform('org.junit:junit-bom:5.9.1') | ||
testImplementation 'org.junit.jupiter:junit-jupiter' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} | ||
|
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,6 @@ | ||
#Tue Jan 02 12:17:35 MST 2024 | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStorePath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME |
Oops, something went wrong.