Skip to content

Commit

Permalink
Initial project
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidek committed Jun 5, 2024
0 parents commit 3a9cee1
Show file tree
Hide file tree
Showing 30 changed files with 3,120 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.ftz filter=lfs diff=lfs merge=lfs -text
153 changes: 153 additions & 0 deletions .github/workflows/build.yml
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
46 changes: 46 additions & 0 deletions .gitignore
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
3 changes: 3 additions & 0 deletions .gitmodules
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
7 changes: 7 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions LICENSE
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.
29 changes: 29 additions & 0 deletions README.md
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`
29 changes: 29 additions & 0 deletions build.gradle
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 added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
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
Loading

0 comments on commit 3a9cee1

Please sign in to comment.