Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zgornel committed Mar 25, 2019
0 parents commit 1e973c5
Show file tree
Hide file tree
Showing 19 changed files with 258 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__*
docs/build/
35 changes: 35 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## Documentation: http://docs.travis-ci.com/user/languages/julia/
language: julia
os:
- linux
- osx
julia:
- 1.0
- nightly
notifications:
email: false
git:
depth: 99999999

## uncomment the following lines to allow failures on nightly julia
## (tests will run but not make your overall status red)
matrix:
allow_failures:
- julia: nightly

jobs:
include:
- stage: "Documentation"
julia: 1.0
os: linux
script:
- julia --project=docs/ -e 'using Pkg;
Pkg.develop(PackageSpec(path=pwd()));
Pkg.instantiate();
Pkg.build() '
- julia --project=docs/ docs/make.jl
after_success: skip

after_success:
# push coverage results to Coveralls
- julia -e '(VERSION >= v"0.7" && using Pkg); Pkg.add("Coverage"); cd(Pkg.dir("EmbeddingsAnalysis")); using Coverage; Coveralls.submit(process_folder()); Codecov.submit(process_folder())'
19 changes: 19 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2019: Corneliu Cofaru.

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.
54 changes: 54 additions & 0 deletions Manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This file is machine-generated - editing it directly is not advised

[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[LinearAlgebra]]
deps = ["Libdl"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[SparseArrays]]
deps = ["LinearAlgebra", "Random"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[Word2Vec]]
deps = ["LinearAlgebra", "Statistics", "Test"]
git-tree-sha1 = "94d341dcb4a3844ab969b2c057f6a3423f930785"
uuid = "c64b6f0f-98cd-51d1-af78-58ae84944834"
version = "0.5.0"
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## EmbeddingsAnalysis Release Notes

v0.1.0
------
- Initial release
9 changes: 9 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name = "EmbeddingsAnalysis"
uuid = "827a7f00-4ef9-11e9-22c6-8dc9c6ee7bf4"
authors = ["Corneliu Cofaru <cornel@oxoaresearch.com>"]
version = "0.1.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Word2Vec = "c64b6f0f-98cd-51d1-af78-58ae84944834"
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
![Alt text](https://github.com/zgornel/EmbeddingsAnalysis.jl/blob/master/docs/src/assets/logo.png)

A package for processing embeddings. At this point, only word embeddings are _de facto_ supported however other types (i.e. graph embeddings) could be used as well.

[![License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE.md)
[![Build Status](https://travis-ci.org/zgornel/EmbeddingsAnalysis.jl.svg?branch=master)](https://travis-ci.org/zgornel/EmbeddingsAnalysis.jl)
[![Coverage Status](https://coveralls.io/repos/github/zgornel/EmbeddingsAnalysis.jl/badge.svg?branch=master)](https://coveralls.io/github/zgornel/EmbeddingsAnalysis.jl?branch=master)
[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://zgornel.github.io/EmbeddingsAnalysis.jl/dev)


## Installation
```julia
using Pkg
Pkg.clone("https://github.com/zgornel/EmbeddingsAnalysis.jl")
```


## Features
To keep track with the latest features, please consult [NEWS.md](https://github.com/zgornel/EmbeddingsAnalysis.jl/blob/master/NEWS.md) and the [documentation](https://zgornel.github.io/EmbeddingsAnalysis.jl/dev).


## License

The code has an MIT license and therefore it is free.


## Reporting Bugs

This is work in progress and bugs may still be present...¯\\_(ツ)_/¯ Do not worry, just [open an issue](https://github.com/zgornel/EmbeddingsAnalysis.jl/issues/new) to report a bug or request a feature.
2 changes: 2 additions & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
julia 1.0
Word2Vec
5 changes: 5 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

[compat]
Documenter = "~0.20"
28 changes: 28 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Pkg
Pkg.add("Documenter")
using Documenter, EmbeddingsAnalysis

# Make src directory available
push!(LOAD_PATH,"../src/")

# Make documentation
makedocs(
modules = [EmbeddingsAnalysis],
format = :html,
sitename = " ",
authors = "Corneliu Cofaru, 0x0α Research",
clean = true,
debug = true,
pages = [
"Introduction" => "index.md",
"API Reference" => "api.md",
]
)

# Deploy documentation
deploydocs(
repo = "github.com/zgornel/EmbeddingsAnalysis.jl.git",
target = "build",
deps = nothing,
make = nothing
)
6 changes: 6 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```@index
```

```@autodocs
Modules = [EmbeddingsAnalysis]
```
Binary file added docs/src/assets/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/assets/svg_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
```@meta
CurrentModule=EmbeddingsAnalysis
```

# Introduction

EmbeddingsAnalysis is a package for processing embeddings. At this point, only word embeddings are _de facto_ supported however other types (i.e. graph embeddings) could be used as well.

## Processing methods
The package implements the following embeddings processing algorithms:
- [Artetxe et al. \"Uncovering divergent linguistic information in word embeddings with lessons for intrinsic and extrinsic evaluation\", 2018](https://arxiv.org/pdf/1809.02094.pdf)

## Installation

Installation can be performed from either outside or inside Julia with:
```
$ git clone https://github.com/zgornel/EmbeddingsAnalysis.jl
```
and
```
using Pkg
Pkg.clone("https://github.com/zgornel/EmbeddingsAnalysis.jl")
```
respectively.
9 changes: 9 additions & 0 deletions src/EmbeddingsAnalysis.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module EmbeddingsAnalysis

using LinearAlgebra
using Word2Vec

export similarity_order

include("similarity_order.jl")
end # module
22 changes: 22 additions & 0 deletions src/similarity_order.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
similarity_order(wv::WordVectors, alpha=-0.65)
Post-processes the word embeddings `wv` so that the embeddings capture more
information than directly apparent through a linear transformation that
adjusts the similarity order of the model. The function returns a new
`WordVectors` object containing the processed embeddings.
# References:
* [Artetxe et al. \"Uncovering divergent linguistic information in
word embeddings with lessons for intrinsic and extrinsic evaluation\",
2018](https://arxiv.org/pdf/1809.02094.pdf)
"""
function similarity_order(wv::WordVectors{S,T,H}, alpha::T=T(-0.65)
) where {S<:AbstractString, T<:Real, H<:Integer}
n = length(wv.vocab)
X = wv.vectors
M = X*X'
L, Q = eigen(M)
Wₐ= Q .* (L.^alpha)
return WordVectors{S,T,H}(wv.vocab, Wₐ*X, wv.vocab_hash)
end
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module TestEmbeddingsAnalysis

using Test
using EmbeddingsAnalysis

include("tests.jl")

end
1 change: 1 addition & 0 deletions test/tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@test true

0 comments on commit 1e973c5

Please sign in to comment.