├── .editorconfig ├── .github ├── FUNDING.yml └── workflows │ └── crystal.yml ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── docs ├── CNAME ├── Cadmium.html ├── Cadmium │ ├── AggressiveTokenizer.html │ ├── BayesClassifier.html │ ├── CaseTokenizer.html │ ├── Classifiers.html │ ├── CountInflector.html │ ├── EdgeWeightedDigraph.html │ ├── EdgeWeightedDigraph │ │ ├── Bag.html │ │ └── DirectedEdge.html │ ├── Graph.html │ ├── Graph │ │ └── ShortestPath.html │ ├── IntExtension.html │ ├── JaroWinklerDistance.html │ ├── LevenshteinDistance.html │ ├── LogisticRegression.html │ ├── Metaphone.html │ ├── NGrams.html │ ├── Normalizers.html │ ├── Normalizers │ │ └── RemoveDiacritics.html │ ├── NounInflector.html │ ├── PairDistance.html │ ├── Phonetics.html │ ├── PorterStemmer.html │ ├── PragmaticTokenizer.html │ ├── PragmaticTokenizer │ │ ├── Languages.html │ │ ├── Languages │ │ │ ├── Common.html │ │ │ ├── Deutsch.html │ │ │ └── English.html │ │ ├── MentionsOptions.html │ │ ├── NumbersOptions.html │ │ └── PunctuationOptions.html │ ├── PresentVerbInflector.html │ ├── Readability.html │ ├── RegexTokenizer.html │ ├── SentenceTokenizer.html │ ├── Sentiment.html │ ├── SoundEx.html │ ├── Stemmer.html │ ├── Stemmer │ │ └── Token.html │ ├── StringExtension.html │ ├── TenseInflector.html │ ├── TenseInflector │ │ └── FormSet.html │ ├── TfIdf.html │ ├── TfIdf │ │ └── Document.html │ ├── Tokenizer.html │ ├── Transliterator.html │ ├── Transliterator │ │ └── StringExtension.html │ ├── TreebankWordTokenizer.html │ ├── Trie.html │ ├── Util.html │ ├── Util │ │ ├── Paragraph.html │ │ ├── Sentence.html │ │ ├── StopWords.html │ │ ├── Syllable.html │ │ └── Syllable │ │ │ └── Guess.html │ ├── VisibleCharTokenizer.html │ ├── WhitespaceTokenizer.html │ ├── WordNet.html │ ├── WordNet │ │ ├── DB.html │ │ ├── Lemma.html │ │ ├── Pointer.html │ │ └── Synset.html │ ├── WordPunctuationTokenizer.html │ └── WordTokenizer.html ├── css │ └── style.css ├── index.html ├── index.json ├── js │ └── doc.js └── search-index.js ├── img ├── cadmium.gvdesign └── cadmium.png ├── shard.yml └── spec └── spec_helper.cr /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cr] 2 | charset = utf-8 3 | end_of_line = lf 4 | insert_final_newline = true 5 | indent_style = space 6 | indent_size = 2 7 | trim_trailing_whitespace = true 8 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: watzon 4 | patreon: watzon 5 | open_collective: cadmium 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with a single custom sponsorship URL 13 | -------------------------------------------------------------------------------- /.github/workflows/crystal.yml: -------------------------------------------------------------------------------- 1 | name: Crystal CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | container: 11 | image: crystallang/crystal 12 | 13 | steps: 14 | - uses: actions/checkout@v1 15 | - name: Install dependencies 16 | run: shards install 17 | - name: Check Formatting 18 | run: crystal tool format --check 19 | - name: Run tests 20 | run: crystal spec 21 | - name: Ameba 22 | run: bin/ameba 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /lib/ 2 | /bin/ 3 | /.shards/ 4 | .gvdesign 5 | .ameba.yml 6 | 7 | # Libraries don't need dependency lock 8 | # Dependencies will be locked in application that uses them 9 | /shard.lock 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: crystal 2 | 3 | install: 4 | - shards install 5 | 6 | script: 7 | - crystal spec 8 | - crystal tool format --check 9 | - bin/ameba 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 Chris Watson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Logo](img/cadmium.png) 2 | 3 | **Cadmium** is a *Natural Language Processing* (NLP) library for [Crystal](https://crystal-lang.org/). 4 | 5 | For full API documentation check out [the docs](https://cadmiumcr.github.io/cadmium/). 6 | 7 | For more complete and up to date information about specific parts of Cadmium, check out each relevant shard repository. 8 | 9 | 10 | 11 | | Shard name | Description | 12 | | ------------------------------------------------------------ | ------------------------------------------------------------ | 13 | | [cadmium_tokenizer](https://github.com/cadmiumcr/tokenizer) | Contains several types of string tokenizers | 14 | | [cadmium_stemmer](https://github.com/cadmiumcr/stemmer) | Contains a Porter stemmer, useful to get the stems of english words | 15 | | [cadmium_ngrams](https://github.com/cadmiumcr/ngrams) | Contains methods to obtain unigram, bigrams, trigrams or ngrams from strings | 16 | | [cadmium_classifier](https://github.com/cadmiumcr/classifier) | Contains two probabilistic classifiers used in NLP operations like language detection or POS tagging for example | 17 | | [cadmium_readability](https://github.com/cadmiumcr/readability) | Analyzes blocks of text and determine, using various algorithms, the readability of the text. | 18 | | [cadmium_tfidf](https://github.com/cadmiumcr/tfidf) | Calculates the Term Frequency–Inverse Document Frequency of a corpus | 19 | | [cadmium_glove](https://github.com/cadmiumcr/glove) | Pure Crystal implementation of Global Vectors for Word Representations | 20 | | [cadmium_pos_tagger](https://github.com/cadmiumcr/pos_tagger) | Tags each token of a text with its Part Of Speech category | 21 | | [cadmium_lemmatizer](https://github.com/cadmiumcr/lemmatizer) | Returns the lemma of each given string token | 22 | | [cadmium_summarizer](https://github.com/cadmiumcr/summarizer) | Extracts the most meaningful sentences of a text to create a summary | 23 | | [cadmium_sentiment](https://github.com/cadmiumcr/sentiment) | Evaluates the sentiment of a text | 24 | | [cadmium_distance](https://github.com/cadmiumcr/distance) | Provides two string distance algorithms | 25 | | [cadmium_transliterator](https://github.com/cadmiumcr/transliterator) | Provides the ability to transliterate UTF-8 strings into pure ASCII so that they can be safely displayed in URL slugs or file names. | 26 | | [cadmium_phonetics](https://github.com/cadmiumcr/phonetics) | Allows to match a string with its sound representation | 27 | | [cadmium_inflector](https://github.com/cadmiumcr/inflector) | Allows to inflect english words (nouns, verbs and numbers) | 28 | | [cadmium_graph](https://github.com/cadmiumcr/graph) | EdgeWeightedDigraph represents a digraph, you can add an edge, get the number vertexes, edges, get all edges and use toString to print the Digraph. | 29 | | [cadmium_trie](https://github.com/cadmiumcr/trie) | A [trie](https://en.wikipedia.org/wiki/Trie) is a data structure for efficiently storing and retrieving strings with identical prefixes, like "**mee**t" and "**mee**k". | 30 | | [cadmium_wordnet](https://github.com/cadmiumcr/wordnet) | Pure crystal implementation of Stanford NLPs WordNet | 31 | | [cadmium_util](https://github.com/cadmiumcr/utilities) | A collection of useful utilities used internally in Cadmium. | 32 | | [cadmium_language_detector](https://github.com/cadmiumcr/language_detector) | Returns the most probable language code of the analysed text. | 33 | 34 | 35 | 36 | 37 | ## Installation 38 | 39 | Your project *should* only include the Cadmium shard(s) you need. 40 | 41 | However, in case you want to test out **all of Cadmium** in a simple way, you can install all modules of the project in a few lines. 42 | 43 | Add this to your application's `shard.yml`: 44 | 45 | ```yaml 46 | dependencies: 47 | cadmium: 48 | github: cadmiumcr/cadmium 49 | branch: master 50 | ``` 51 | 52 | ## Contributing 53 | 54 | 1. Fork it ( https://github.com/cadmiumcr/cadmium/fork ) 55 | 2. Create your feature branch (git checkout -b my-new-feature) 56 | 3. Commit your changes (git commit -am 'Add some feature') 57 | 4. Push to the branch (git push origin my-new-feature) 58 | 5. Create a new Pull Request 59 | 60 | ## Contributors 61 | 62 | This project exists thanks to all the people who contribute. 63 | -------------------------------------------------------------------------------- /docs/CNAME: -------------------------------------------------------------------------------- 1 | api.cadmiumcr.com -------------------------------------------------------------------------------- /docs/Cadmium/Classifiers.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | Cadmium::Classifiers - github.com/watzon/cadmium 18 | 19 | 20 | 21 | 428 | 429 | 430 |
431 |

432 | 433 | module Cadmium::Classifiers 434 | 435 |

436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 |

Defined in:

455 | 456 | 457 | 458 | cadmium/classifier.cr 459 | 460 | 461 |
462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 |
477 | 478 |
479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 |
489 | 490 | 491 | 492 | -------------------------------------------------------------------------------- /docs/Cadmium/Graph.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | Cadmium::Graph - github.com/watzon/cadmium 18 | 19 | 20 | 21 | 428 | 429 | 430 |
431 |

432 | 433 | module Cadmium::Graph 434 | 435 |

436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 |

Defined in:

455 | 456 | 457 | 458 | cadmium/graph/shortest_path.cr 459 | 460 | 461 |
462 | 463 | 464 | 465 | cadmium/graph.cr 466 | 467 | 468 |
469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 |
484 | 485 |
486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 |
496 | 497 | 498 | 499 | -------------------------------------------------------------------------------- /docs/Cadmium/Graph/ShortestPath.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | Cadmium::Graph::ShortestPath - github.com/watzon/cadmium 18 | 19 | 20 | 21 | 428 | 429 | 430 |
431 |

432 | 433 | class Cadmium::Graph::ShortestPath 434 | 435 |

436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 |

Defined in:

457 | 458 | 459 | 460 | cadmium/graph/shortest_path.cr 461 | 462 | 463 |
464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 |
479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 |
501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 |
511 | 512 | 513 | 514 | -------------------------------------------------------------------------------- /docs/Cadmium/IntExtension.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | Cadmium::IntExtension - github.com/watzon/cadmium 18 | 19 | 20 | 21 | 428 | 429 | 430 |
431 |

432 | 433 | module Cadmium::IntExtension 434 | 435 |

436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 |

Defined in:

455 | 456 | 457 | 458 | cadmium/inflectors.cr 459 | 460 | 461 |
462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 |

Instance Method Summary

473 | 481 | 482 | 483 | 484 | 485 | 486 |
487 | 488 |
489 | 490 | 491 | 492 | 493 | 494 | 495 |

Instance Method Detail

496 | 497 |
498 |
499 | 500 | def to_nth 501 | 502 | # 503 |
504 | 505 |
506 |
507 | 508 | [View source] 509 | 510 |
511 |
512 | 513 | 514 | 515 | 516 | 517 |
518 | 519 | 520 | 521 | -------------------------------------------------------------------------------- /docs/Cadmium/LogisticRegression.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | Cadmium::LogisticRegression - github.com/watzon/cadmium 18 | 19 | 20 | 21 | 428 | 429 | 430 |
431 |

432 | 433 | class Cadmium::LogisticRegression 434 | 435 |

436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 |

Defined in:

457 | 458 | 459 | 460 | cadmium/classifier/logistic_regression.cr 461 | 462 | 463 |
464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 |
479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 |
501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 |
511 | 512 | 513 | 514 | -------------------------------------------------------------------------------- /docs/Cadmium/Normalizers.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | Cadmium::Normalizers - github.com/watzon/cadmium 18 | 19 | 20 | 21 | 428 | 429 | 430 |
431 |

432 | 433 | module Cadmium::Normalizers 434 | 435 |

436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 |

Defined in:

455 | 456 | 457 | 458 | cadmium/normalizers/remove_diacritics.cr 459 | 460 | 461 |
462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 |
477 | 478 |
479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 |
489 | 490 | 491 | 492 | -------------------------------------------------------------------------------- /docs/Cadmium/TfIdf/Document.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | Cadmium::TfIdf::Document - github.com/watzon/cadmium 18 | 19 | 20 | 21 | 428 | 429 | 430 |
431 |

432 | 433 | alias Cadmium::TfIdf::Document 434 | 435 |

436 | 437 | 438 | 439 | 440 | 441 |

Overview

442 | 443 |

TODO Figure out how to make this work with no key

444 | 445 | 446 | 447 |

Alias Definition

448 | {key: String, terms: Hash(String, Float64)} 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 |

Defined in:

462 | 463 | 464 | 465 | cadmium/tfidf.cr 466 | 467 | 468 |
469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 |
484 | 485 |
486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 |
496 | 497 | 498 | 499 | -------------------------------------------------------------------------------- /docs/Cadmium/Transliterator/StringExtension.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | Cadmium::Transliterator::StringExtension - github.com/watzon/cadmium 18 | 19 | 20 | 21 | 428 | 429 | 430 |
431 |

432 | 433 | module Cadmium::Transliterator::StringExtension 434 | 435 |

436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 |

Defined in:

455 | 456 | 457 | 458 | cadmium/transliterator.cr 459 | 460 | 461 |
462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 |

Instance Method Summary

473 | 481 | 482 | 483 | 484 | 485 | 486 |
487 | 488 |
489 | 490 | 491 | 492 | 493 | 494 | 495 |

Instance Method Detail

496 | 497 |
498 |
499 | 500 | def transliterate(**options) 501 | 502 | # 503 |
504 | 505 |
506 |
507 | 508 | [View source] 509 | 510 |
511 |
512 | 513 | 514 | 515 | 516 | 517 |
518 | 519 | 520 | 521 | -------------------------------------------------------------------------------- /docs/Cadmium/Util.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | Cadmium::Util - github.com/watzon/cadmium 18 | 19 | 20 | 21 | 428 | 429 | 430 |
431 |

432 | 433 | module Cadmium::Util 434 | 435 |

436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 |

Defined in:

455 | 456 | 457 | 458 | cadmium/util/stop_words.cr 459 | 460 | 461 |
462 | 463 | 464 | 465 | cadmium/util/paragraph.cr 466 | 467 | 468 |
469 | 470 | 471 | 472 | cadmium/util/sentence.cr 473 | 474 | 475 |
476 | 477 | 478 | 479 | cadmium/util/syllable.cr 480 | 481 | 482 |
483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 |
498 | 499 |
500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 |
510 | 511 | 512 | 513 | -------------------------------------------------------------------------------- /docs/Cadmium/Util/Paragraph.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | Cadmium::Util::Paragraph - github.com/watzon/cadmium 18 | 19 | 20 | 21 | 428 | 429 | 430 |
431 |

432 | 433 | module Cadmium::Util::Paragraph 434 | 435 |

436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 |

Defined in:

455 | 456 | 457 | 458 | cadmium/util/paragraph.cr 459 | 460 | 461 |
462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 |

Class Method Summary

471 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 |
489 | 490 |
491 | 492 | 493 | 494 | 495 |

Class Method Detail

496 | 497 |
498 |
499 | 500 | def self.paragraphs(text) 501 | 502 | # 503 |
504 | 505 |

Splits text into an array of paragraphs.

506 | 507 |
508 |
509 | 510 | [View source] 511 | 512 |
513 |
514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 |
522 | 523 | 524 | 525 | -------------------------------------------------------------------------------- /docs/Cadmium/Util/StopWords.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | Cadmium::Util::StopWords - github.com/watzon/cadmium 18 | 19 | 20 | 21 | 428 | 429 | 430 |
431 |

432 | 433 | module Cadmium::Util::StopWords 434 | 435 |

436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 |

Direct including types

452 | 461 | 462 | 463 | 464 | 465 |

Defined in:

466 | 467 | 468 | 469 | cadmium/util/stop_words.cr 470 | 471 | 472 |
473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 |
488 | 489 |
490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 |
500 | 501 | 502 | 503 | -------------------------------------------------------------------------------- /docs/css/style.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | background: #FFFFFF; 3 | position: relative; 4 | margin: 0; 5 | padding: 0; 6 | width: 100%; 7 | height: 100%; 8 | overflow: hidden; 9 | } 10 | 11 | body { 12 | font-family: "Avenir", "Tahoma", "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif; 13 | color: #333; 14 | line-height: 1.5; 15 | } 16 | 17 | a { 18 | color: #263F6C; 19 | } 20 | 21 | a:visited { 22 | color: #112750; 23 | } 24 | 25 | h1, h2, h3, h4, h5, h6 { 26 | margin: 35px 0 25px; 27 | color: #444444; 28 | } 29 | 30 | h1.type-name { 31 | color: #47266E; 32 | margin: 20px 0 30px; 33 | background-color: #F8F8F8; 34 | padding: 10px 12px; 35 | border: 1px solid #EBEBEB; 36 | border-radius: 2px; 37 | } 38 | 39 | h2 { 40 | border-bottom: 1px solid #E6E6E6; 41 | padding-bottom: 5px; 42 | } 43 | 44 | body { 45 | display: flex; 46 | } 47 | 48 | .sidebar, .main-content { 49 | overflow: auto; 50 | } 51 | 52 | .sidebar { 53 | width: 30em; 54 | color: #F8F4FD; 55 | background-color: #2E1052; 56 | padding: 0 0 30px; 57 | box-shadow: inset -3px 0 4px rgba(0,0,0,.35); 58 | line-height: 1.2; 59 | } 60 | 61 | .sidebar .search-box { 62 | padding: 8px 9px; 63 | } 64 | 65 | .sidebar input { 66 | display: block; 67 | box-sizing: border-box; 68 | margin: 0; 69 | padding: 5px; 70 | font: inherit; 71 | font-family: inherit; 72 | line-height: 1.2; 73 | width: 100%; 74 | border: 0; 75 | outline: 0; 76 | border-radius: 2px; 77 | box-shadow: 0px 3px 5px rgba(0,0,0,.25); 78 | transition: box-shadow .12s; 79 | } 80 | 81 | .sidebar input:focus { 82 | box-shadow: 0px 5px 6px rgba(0,0,0,.5); 83 | } 84 | 85 | .sidebar input::-webkit-input-placeholder { /* Chrome/Opera/Safari */ 86 | color: #C8C8C8; 87 | font-size: 14px; 88 | text-indent: 2px; 89 | } 90 | 91 | .sidebar input::-moz-placeholder { /* Firefox 19+ */ 92 | color: #C8C8C8; 93 | font-size: 14px; 94 | text-indent: 2px; 95 | } 96 | 97 | .sidebar input:-ms-input-placeholder { /* IE 10+ */ 98 | color: #C8C8C8; 99 | font-size: 14px; 100 | text-indent: 2px; 101 | } 102 | 103 | .sidebar input:-moz-placeholder { /* Firefox 18- */ 104 | color: #C8C8C8; 105 | font-size: 14px; 106 | text-indent: 2px; 107 | } 108 | 109 | .sidebar ul { 110 | margin: 0; 111 | padding: 0; 112 | list-style: none outside; 113 | } 114 | 115 | .sidebar li { 116 | display: block; 117 | position: relative; 118 | } 119 | 120 | .types-list li.hide { 121 | display: none; 122 | } 123 | 124 | .sidebar a { 125 | text-decoration: none; 126 | color: inherit; 127 | transition: color .14s; 128 | } 129 | .types-list a { 130 | display: block; 131 | padding: 5px 15px 5px 30px; 132 | } 133 | 134 | .types-list { 135 | display: block; 136 | } 137 | 138 | .sidebar a:focus { 139 | outline: 1px solid #D1B7F1; 140 | } 141 | 142 | .types-list a { 143 | padding: 5px 15px 5px 30px; 144 | } 145 | 146 | .sidebar .current > a, 147 | .sidebar a:hover { 148 | color: #866BA6; 149 | } 150 | 151 | .repository-links { 152 | padding: 5px 15px 5px 30px; 153 | } 154 | 155 | .types-list li ul { 156 | overflow: hidden; 157 | height: 0; 158 | max-height: 0; 159 | transition: 1s ease-in-out; 160 | } 161 | 162 | .types-list li.parent { 163 | padding-left: 30px; 164 | } 165 | 166 | .types-list li.parent::before { 167 | box-sizing: border-box; 168 | content: "▼"; 169 | display: block; 170 | width: 30px; 171 | height: 30px; 172 | position: absolute; 173 | top: 0; 174 | left: 0; 175 | text-align: center; 176 | color: white; 177 | font-size: 8px; 178 | line-height: 30px; 179 | transform: rotateZ(-90deg); 180 | cursor: pointer; 181 | transition: .2s linear; 182 | } 183 | 184 | 185 | .types-list li.parent > a { 186 | padding-left: 0; 187 | } 188 | 189 | .types-list li.parent.open::before { 190 | transform: rotateZ(0); 191 | } 192 | 193 | .types-list li.open > ul { 194 | height: auto; 195 | max-height: 1000em; 196 | } 197 | 198 | .main-content { 199 | padding: 0 30px 30px 30px; 200 | width: 100%; 201 | } 202 | 203 | .kind { 204 | font-size: 60%; 205 | color: #866BA6; 206 | } 207 | 208 | .superclass-hierarchy { 209 | margin: -15px 0 30px 0; 210 | padding: 0; 211 | list-style: none outside; 212 | font-size: 80%; 213 | } 214 | 215 | .superclass-hierarchy .superclass { 216 | display: inline-block; 217 | margin: 0 7px 0 0; 218 | padding: 0; 219 | } 220 | 221 | .superclass-hierarchy .superclass + .superclass::before { 222 | content: "<"; 223 | margin-right: 7px; 224 | } 225 | 226 | .other-types-list li { 227 | display: inline-block; 228 | } 229 | 230 | .other-types-list, 231 | .list-summary { 232 | margin: 0 0 30px 0; 233 | padding: 0; 234 | list-style: none outside; 235 | } 236 | 237 | .entry-const { 238 | font-family: Menlo, Monaco, Consolas, 'Courier New', Courier, monospace; 239 | } 240 | 241 | .entry-const code { 242 | white-space: pre-wrap; 243 | } 244 | 245 | .entry-summary { 246 | padding-bottom: 4px; 247 | } 248 | 249 | .superclass-hierarchy .superclass a, 250 | .other-type a, 251 | .entry-summary .signature { 252 | padding: 4px 8px; 253 | margin-bottom: 4px; 254 | display: inline-block; 255 | background-color: #f8f8f8; 256 | color: #47266E; 257 | border: 1px solid #f0f0f0; 258 | text-decoration: none; 259 | border-radius: 3px; 260 | font-family: Menlo, Monaco, Consolas, 'Courier New', Courier, monospace; 261 | transition: background .15s, border-color .15s; 262 | } 263 | 264 | .superclass-hierarchy .superclass a:hover, 265 | .other-type a:hover, 266 | .entry-summary .signature:hover { 267 | background: #D5CAE3; 268 | border-color: #624288; 269 | } 270 | 271 | .entry-summary .summary { 272 | padding-left: 32px; 273 | } 274 | 275 | .entry-summary .summary p { 276 | margin: 12px 0 16px; 277 | } 278 | 279 | .entry-summary a { 280 | text-decoration: none; 281 | } 282 | 283 | .entry-detail { 284 | padding: 30px 0; 285 | } 286 | 287 | .entry-detail .signature { 288 | position: relative; 289 | padding: 5px 15px; 290 | margin-bottom: 10px; 291 | display: block; 292 | border-radius: 5px; 293 | background-color: #f8f8f8; 294 | color: #47266E; 295 | border: 1px solid #f0f0f0; 296 | font-family: Menlo, Monaco, Consolas, 'Courier New', Courier, monospace; 297 | transition: .2s ease-in-out; 298 | } 299 | 300 | .entry-detail:target .signature { 301 | background-color: #D5CAE3; 302 | border: 1px solid #624288; 303 | } 304 | 305 | .entry-detail .signature .method-permalink { 306 | position: absolute; 307 | top: 0; 308 | left: -35px; 309 | padding: 5px 15px; 310 | text-decoration: none; 311 | font-weight: bold; 312 | color: #624288; 313 | opacity: .4; 314 | transition: opacity .2s; 315 | } 316 | 317 | .entry-detail .signature .method-permalink:hover { 318 | opacity: 1; 319 | } 320 | 321 | .entry-detail:target .signature .method-permalink { 322 | opacity: 1; 323 | } 324 | 325 | .methods-inherited { 326 | padding-right: 10%; 327 | line-height: 1.5em; 328 | } 329 | 330 | .methods-inherited h3 { 331 | margin-bottom: 4px; 332 | } 333 | 334 | .methods-inherited a { 335 | display: inline-block; 336 | text-decoration: none; 337 | color: #47266E; 338 | } 339 | 340 | .methods-inherited a:hover { 341 | text-decoration: underline; 342 | color: #6C518B; 343 | } 344 | 345 | .methods-inherited .tooltip>span { 346 | background: #D5CAE3; 347 | padding: 4px 8px; 348 | border-radius: 3px; 349 | margin: -4px -8px; 350 | } 351 | 352 | .methods-inherited .tooltip * { 353 | color: #47266E; 354 | } 355 | 356 | pre { 357 | padding: 10px 20px; 358 | margin-top: 4px; 359 | border-radius: 3px; 360 | line-height: 1.45; 361 | overflow: auto; 362 | color: #333; 363 | background: #fdfdfd; 364 | font-size: 14px; 365 | border: 1px solid #eee; 366 | } 367 | 368 | code { 369 | font-family: Menlo, Monaco, Consolas, 'Courier New', Courier, monospace; 370 | } 371 | 372 | :not(pre) > code { 373 | background-color: rgba(40,35,30,0.05); 374 | padding: 0.2em 0.4em; 375 | font-size: 85%; 376 | border-radius: 3px; 377 | } 378 | 379 | span.flag { 380 | padding: 2px 4px 1px; 381 | border-radius: 3px; 382 | margin-right: 3px; 383 | font-size: 11px; 384 | border: 1px solid transparent; 385 | } 386 | 387 | span.flag.orange { 388 | background-color: #EE8737; 389 | color: #FCEBDD; 390 | border-color: #EB7317; 391 | } 392 | 393 | span.flag.yellow { 394 | background-color: #E4B91C; 395 | color: #FCF8E8; 396 | border-color: #B69115; 397 | } 398 | 399 | span.flag.green { 400 | background-color: #469C14; 401 | color: #E2F9D3; 402 | border-color: #34700E; 403 | } 404 | 405 | span.flag.red { 406 | background-color: #BF1919; 407 | color: #F9ECEC; 408 | border-color: #822C2C; 409 | } 410 | 411 | span.flag.purple { 412 | background-color: #2E1052; 413 | color: #ECE1F9; 414 | border-color: #1F0B37; 415 | } 416 | 417 | .tooltip>span { 418 | position: absolute; 419 | opacity: 0; 420 | display: none; 421 | pointer-events: none; 422 | } 423 | 424 | .tooltip:hover>span { 425 | display: inline-block; 426 | opacity: 1; 427 | } 428 | 429 | .c { 430 | color: #969896; 431 | } 432 | 433 | .n { 434 | color: #0086b3; 435 | } 436 | 437 | .t { 438 | color: #0086b3; 439 | } 440 | 441 | .s { 442 | color: #183691; 443 | } 444 | 445 | .i { 446 | color: #7f5030; 447 | } 448 | 449 | .k { 450 | color: #a71d5d; 451 | } 452 | 453 | .o { 454 | color: #a71d5d; 455 | } 456 | 457 | .m { 458 | color: #795da3; 459 | } 460 | 461 | .hidden { 462 | display: none; 463 | } 464 | .search-results { 465 | font-size: 90%; 466 | line-height: 1.3; 467 | } 468 | 469 | .search-results mark { 470 | color: inherit; 471 | background: transparent; 472 | font-weight: bold; 473 | } 474 | .search-result { 475 | padding: 5px 8px 5px 5px; 476 | cursor: pointer; 477 | border-left: 5px solid transparent; 478 | transform: translateX(-3px); 479 | transition: all .2s, background-color 0s, border .02s; 480 | min-height: 3.2em; 481 | } 482 | .search-result.current { 483 | border-left-color: #ddd; 484 | background-color: rgba(200,200,200,0.4); 485 | transform: translateX(0); 486 | transition: all .2s, background-color .5s, border 0s; 487 | } 488 | .search-result.current:hover, 489 | .search-result.current:focus { 490 | border-left-color: #866BA6; 491 | } 492 | .search-result:not(.current):nth-child(2n) { 493 | background-color: rgba(255,255,255,.06); 494 | } 495 | .search-result__title { 496 | font-size: 105%; 497 | word-break: break-all; 498 | line-height: 1.1; 499 | padding: 3px 0; 500 | } 501 | .search-result__title strong { 502 | font-weight: normal; 503 | } 504 | .search-results .search-result__title > a { 505 | padding: 0; 506 | display: block; 507 | } 508 | .search-result__title > a > .args { 509 | color: #dddddd; 510 | font-weight: 300; 511 | transition: inherit; 512 | font-size: 88%; 513 | line-height: 1.2; 514 | letter-spacing: -.02em; 515 | } 516 | .search-result__title > a > .args * { 517 | color: inherit; 518 | } 519 | 520 | .search-result a, 521 | .search-result a:hover { 522 | color: inherit; 523 | } 524 | .search-result:not(.current):hover .search-result__title > a, 525 | .search-result:not(.current):focus .search-result__title > a, 526 | .search-result__title > a:focus { 527 | color: #866BA6; 528 | } 529 | .search-result:not(.current):hover .args, 530 | .search-result:not(.current):focus .args { 531 | color: #6a5a7d; 532 | } 533 | 534 | .search-result__type { 535 | color: #e8e8e8; 536 | font-weight: 300; 537 | } 538 | .search-result__doc { 539 | color: #bbbbbb; 540 | font-size: 90%; 541 | } 542 | .search-result__doc p { 543 | margin: 0; 544 | text-overflow: ellipsis; 545 | display: -webkit-box; 546 | -webkit-box-orient: vertical; 547 | -webkit-line-clamp: 2; 548 | overflow: hidden; 549 | line-height: 1.2em; 550 | max-height: 2.4em; 551 | } 552 | 553 | .js-modal-visible .modal-background { 554 | display: flex; 555 | } 556 | .main-content { 557 | position: relative; 558 | } 559 | .modal-background { 560 | position: absolute; 561 | display: none; 562 | height: 100%; 563 | width: 100%; 564 | background: rgba(120,120,120,.4); 565 | z-index: 100; 566 | align-items: center; 567 | justify-content: center; 568 | } 569 | .usage-modal { 570 | max-width: 90%; 571 | background: #fff; 572 | border: 2px solid #ccc; 573 | border-radius: 9px; 574 | padding: 5px 15px 20px; 575 | min-width: 50%; 576 | color: #555; 577 | position: relative; 578 | transform: scale(.5); 579 | transition: transform 200ms; 580 | } 581 | .js-modal-visible .usage-modal { 582 | transform: scale(1); 583 | } 584 | .usage-modal > .close-button { 585 | position: absolute; 586 | right: 15px; 587 | top: 8px; 588 | color: #aaa; 589 | font-size: 27px; 590 | cursor: pointer; 591 | } 592 | .usage-modal > .close-button:hover { 593 | text-shadow: 2px 2px 2px #ccc; 594 | color: #999; 595 | } 596 | .modal-title { 597 | margin: 0; 598 | text-align: center; 599 | font-weight: normal; 600 | color: #666; 601 | border-bottom: 2px solid #ddd; 602 | padding: 10px; 603 | } 604 | .usage-list { 605 | padding: 0; 606 | margin: 13px; 607 | } 608 | .usage-list > li { 609 | padding: 5px 2px; 610 | overflow: auto; 611 | padding-left: 100px; 612 | min-width: 12em; 613 | } 614 | .usage-modal kbd { 615 | background: #eee; 616 | border: 1px solid #ccc; 617 | border-bottom-width: 2px; 618 | border-radius: 3px; 619 | padding: 3px 8px; 620 | font-family: monospace; 621 | margin-right: 2px; 622 | display: inline-block; 623 | } 624 | .usage-key { 625 | float: left; 626 | clear: left; 627 | margin-left: -100px; 628 | margin-right: 12px; 629 | } 630 | -------------------------------------------------------------------------------- /img/cadmium.gvdesign: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadmiumcr/cadmium/aef050e08faf07f2d5933cdd9c9356dad7ec413a/img/cadmium.gvdesign -------------------------------------------------------------------------------- /img/cadmium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cadmiumcr/cadmium/aef050e08faf07f2d5933cdd9c9356dad7ec413a/img/cadmium.png -------------------------------------------------------------------------------- /shard.yml: -------------------------------------------------------------------------------- 1 | name: cadmium 2 | version: 0.3.0 3 | 4 | authors: 5 | - Chris Watson 6 | - Rémy Marronnier 7 | 8 | crystal: 0.31.1 9 | 10 | dependencies: 11 | cadmium_language_detector: 12 | github: cadmiumcr/language_detector 13 | cadmium_lemmatizer: 14 | github: cadmiumcr/lemmatizer 15 | cadmium_readability: 16 | github: cadmiumcr/readability 17 | cadmium_ngrams: 18 | github: cadmiumcr/ngrams 19 | cadmium_summarizer: 20 | github: cadmiumcr/summarizer 21 | cadmium_sentiment: 22 | github: cadmiumcr/sentiment 23 | cadmium_distance: 24 | github: cadmiumcr/distance 25 | cadmium_tfidf: 26 | github: cadmiumcr/tfidf 27 | cadmium_phonetics: 28 | github: cadmiumcr/phonetics 29 | cadmium_inflector: 30 | github: cadmiumcr/inflector 31 | cadmium_graph: 32 | github: cadmiumcr/graph 33 | cadmium_trie: 34 | github: cadmiumcr/trie 35 | cadmium_transliterator: 36 | github: cadmiumcr/transliterator 37 | cadmium_glove: 38 | github: cadmiumcr/glove 39 | cadmium_wordnet: 40 | github: cadmiumcr/wordnet 41 | 42 | development_dependencies: 43 | ameba: 44 | github: veelenga/ameba 45 | version: 0.10.1 46 | 47 | license: MIT 48 | -------------------------------------------------------------------------------- /spec/spec_helper.cr: -------------------------------------------------------------------------------- 1 | require "spec" 2 | --------------------------------------------------------------------------------