-
Notifications
You must be signed in to change notification settings - Fork 124
Add RBS type signatures #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,2 @@ | ||
| module Classifier | ||
| end |
This file contains hidden or 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,26 @@ | ||
| module Classifier | ||
| class Bayes | ||
| @categories: Hash[Symbol, Hash[Symbol, Integer]] | ||
| @total_words: Integer | ||
| @category_counts: Hash[Symbol, Integer] | ||
| @category_word_count: Hash[Symbol, Integer] | ||
|
|
||
| def initialize: (*_ToS categories) -> void | ||
|
|
||
| def train: (_ToS category, String text) -> void | ||
|
|
||
| def untrain: (_ToS category, String text) -> void | ||
|
|
||
| def classifications: (String text) -> Hash[String, Float] | ||
|
|
||
| def classify: (String text) -> String | ||
|
|
||
| def categories: () -> Array[String] | ||
|
|
||
| def add_category: (_ToS category) -> Hash[Symbol, Integer] | ||
|
|
||
| alias append_category add_category | ||
|
|
||
| def remove_category: (_ToS category) -> void | ||
| end | ||
| end |
This file contains hidden or 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 @@ | ||
| class Object | ||
| def prepare_category_name: () -> Symbol | ||
| end |
This file contains hidden or 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,25 @@ | ||
| class String | ||
| CORPUS_SKIP_WORDS: Set[String] | ||
|
|
||
| def without_punctuation: () -> String | ||
|
|
||
| def word_hash: () -> Hash[Symbol, Integer] | ||
|
|
||
| def clean_word_hash: () -> Hash[Symbol, Integer] | ||
|
|
||
| def summary: (?Integer count, ?String separator) -> String | ||
|
|
||
| def paragraph_summary: (?Integer count, ?String separator) -> String | ||
|
|
||
| def split_sentences: () -> Array[String] | ||
|
|
||
| def split_paragraphs: () -> Array[String] | ||
|
|
||
| private | ||
|
|
||
| def word_hash_for_words: (Array[String] words) -> Hash[Symbol, Integer] | ||
|
|
||
| def word_hash_for_symbols: (Array[String] words) -> Hash[Symbol, Integer] | ||
cardmagic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| def perform_lsi: (Array[String] chunks, Integer count, String separator) -> String | ||
| end | ||
This file contains hidden or 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,23 @@ | ||
| class Array[unchecked out Elem] | ||
| def sum_with_identity: (?Float identity) ?{ (Elem) -> Numeric } -> Float | ||
| end | ||
|
|
||
| module VectorExtensions | ||
| def magnitude: () -> Float | ||
|
|
||
| def normalize: () -> Vector[Rational] | ||
| end | ||
|
|
||
| class Vector[out Elem] | ||
| include VectorExtensions | ||
| end | ||
|
|
||
| class Matrix[out Elem] | ||
| def self.diag: (Array[Numeric] diagonal_elements) -> Matrix[Numeric] | ||
|
|
||
| def trans: () -> Matrix[Elem] | ||
|
|
||
| def SV_decomp: (?Integer max_sweeps) -> [Matrix[Numeric], Matrix[Numeric], Array[Float]] | ||
|
|
||
| def []=: (Integer row_index, Integer col_index, Numeric value) -> Numeric | ||
| end |
This file contains hidden or 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,57 @@ | ||
| module Classifier | ||
| class LSI | ||
| @auto_rebuild: bool | ||
| @word_list: WordList | ||
| @items: Hash[untyped, ContentNode] | ||
| @version: Integer | ||
| @built_at_version: Integer | ||
|
|
||
| attr_reader word_list: WordList | ||
| attr_accessor auto_rebuild: bool | ||
|
|
||
| def self.gsl_available: () -> bool | ||
| def self.gsl_available=: (bool value) -> bool | ||
|
|
||
| def initialize: (?Hash[Symbol, untyped] options) -> void | ||
|
|
||
| def needs_rebuild?: () -> bool | ||
|
|
||
| def add_item: (untyped item, *untyped categories) ?{ (untyped) -> String } -> void | ||
|
|
||
| def <<: (untyped item) -> void | ||
|
|
||
| def categories_for: (untyped item) -> Array[untyped] | ||
|
|
||
| def remove_item: (untyped item) -> void | ||
|
|
||
| def items: () -> Array[untyped] | ||
|
|
||
| def build_index: (?Float cutoff) -> void | ||
|
|
||
| def highest_relative_content: (?Integer max_chunks) -> Array[untyped] | ||
|
|
||
| def proximity_array_for_content: (untyped doc) ?{ (untyped) -> String } -> Array[[untyped, Float]] | ||
|
|
||
| def proximity_norms_for_content: (untyped doc) ?{ (untyped) -> String } -> Array[[untyped, Float]] | ||
|
|
||
| def search: (String string, ?Integer max_nearest) -> Array[untyped] | ||
|
|
||
| def find_related: (untyped doc, ?Integer max_nearest) ?{ (untyped) -> String } -> Array[untyped] | ||
|
|
||
| def classify: (untyped doc, ?Float cutoff) ?{ (untyped) -> String } -> untyped | ||
|
|
||
| def vote: (untyped doc, ?Float cutoff) ?{ (untyped) -> String } -> Hash[untyped, Float] | ||
|
|
||
| def classify_with_confidence: (untyped doc, ?Float cutoff) ?{ (untyped) -> String } -> [untyped, Float?] | ||
|
|
||
| def highest_ranked_stems: (untyped doc, ?Integer count) -> Array[Symbol] | ||
|
|
||
| private | ||
|
|
||
| def build_reduced_matrix: (untyped matrix, ?Float cutoff) -> untyped | ||
|
|
||
| def node_for_content: (untyped item) ?{ (untyped) -> String } -> ContentNode | ||
|
|
||
| def make_word_list: () -> void | ||
| end | ||
| end |
This file contains hidden or 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,22 @@ | ||
| module Classifier | ||
| class ContentNode | ||
| @word_hash: Hash[Symbol, Integer] | ||
| @categories: Array[untyped] | ||
|
|
||
| attr_accessor raw_vector: untyped | ||
| attr_accessor raw_norm: untyped | ||
| attr_accessor lsi_vector: untyped | ||
| attr_accessor lsi_norm: untyped | ||
| attr_accessor categories: Array[untyped] | ||
|
|
||
| attr_reader word_hash: Hash[Symbol, Integer] | ||
|
|
||
| def initialize: (Hash[Symbol, Integer] word_frequencies, *untyped categories) -> void | ||
|
|
||
| def search_vector: () -> untyped | ||
|
|
||
| def search_norm: () -> untyped | ||
|
|
||
| def raw_vector_with: (WordList word_list) -> untyped | ||
| end | ||
| end |
This file contains hidden or 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,15 @@ | ||
| module Classifier | ||
| class WordList | ||
| @location_table: Hash[Symbol, Integer] | ||
|
|
||
| def initialize: () -> void | ||
|
|
||
| def add_word: (Symbol word) -> Integer? | ||
|
|
||
| def []: (Symbol lookup) -> Integer? | ||
|
|
||
| def word_for_index: (Integer ind) -> Symbol? | ||
|
|
||
| def size: () -> Integer | ||
| end | ||
| end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.