use DSL::Shared::Utilities::FuzzyMatching;

# Recommender specific phrases
role DSL::English::RecommenderWorkflows::Grammar::RecommenderPhrases {

    token word-spec { \w+ }

    # Regular tokens / rules
    token across-adverb { <across-preposition> }
    token across-preposition { 'across' }
    token aggregate-verb { 'aggregate' }
    token aggregation-noun { 'aggregation' }
    token anomalies-noun { 'anomalies' }
    token anomaly-noun { 'anomaly' }
    token colnames-noun { 'colnames' }
    token consumption-noun { 'consumption' }
    token density-noun { 'density' }
    token explain-verb { 'explain' }
    token explanations-noun { 'explanation' | 'explanations' }
    token history-noun { 'history' }
    token item-noun { 'item' }
    token items-noun { 'items' }
    token metadata-noun {'metadata' }
    token most-determiner { 'most' }
    token must-verb { 'must' }
    token must-not-verb { 'must' \h+ 'not' | 'must-not' }
    token profile-noun { 'profile' }
    token proofs-noun { 'proof' | 'proofs' }
    token properties-noun { 'properties' }
    token property-noun { 'property' }
    token prove-verb { 'prove' }
    token proximity-noun { 'proximity' }
    token recommend-directive { <recommend-verb> }
    token recommend-verb { 'recommend' | 'suggest' }
    token recommendation-noun { 'recommendation' }
    token recommendations-noun { 'recommendations' }
    token recommended-adjective { 'recommended' }
    token recommender-noun { 'recommender' }
    token relevant-adjective { 'relevant' }
    token retrieve-verb { 'retrieve' }
    token rownames-noun { 'rownames' }
    token tag-adjective { <tag-noun> }
    token tag-noun { 'tag' }
    token tags-noun { 'tags' }
    token should-verb { 'should' }
    token sub-matrix-noun { 'sub' \h+ '-' \h+ <matrix-noun> }
    token sub-matrices-noun { 'sub' \h+ '-' \h+ <matrices-noun> }

    rule prove-directive { <prove-verb> | <explain-verb> }
    rule consumption-history-phrase { <consumption-noun>? <history-noun> }
    rule consumption-profile-phrase { <consumption-noun>? <profile-noun> }
    rule cross-tabulate-phrase { 'cross' [ 'tabulate' | 'tabulation' ] }
    rule extend-recommendations-phrase { [ <extend-verb> | <join-verb> [ <across-preposition> | <across-adverb> ]? ] <recommendations-noun>? }
    rule history-phrase { [ <item-noun> ]? <history-noun> }
    rule most-relevant { <most-determiner> <relevant-adjective> }
    rule nearest-neighbors { <nearest-adjective> <neighbors-noun> | 'nns' }
    rule recommendation-matrices { [ <recommendation-noun> | <recommender-noun> ]? <matrices-noun> }
    rule recommendation-matrix { [ <recommendation-noun> | <recommender-noun> ]? <matrix-noun> }
    rule recommendation-results { [ <recommendation-noun> | <recommendations-noun> | <recommended-adjective> | 'recommendation\'s' ] <results> }
    rule recommended-items { <recommended-adjective> <items-noun> | [ <recommendations-noun> | <recommendation-noun> | <recommended-adjective> ] <.results>? }
    rule recommender-object-phrase { [ <recommender-noun> | 'smr' ]  [ <object-noun> | <system-noun> ]? }
    rule sparse-matrix { <sparse-adjective> <matrix-noun> }
    rule sub-matrices-phrase { <sub-matrices-noun> | <sub-prefix> <matrices-noun> | <sub-prefix> <matrixes-noun> }
    rule sub-matrix-phrase { <sub-matrix-noun> | <sub-prefix> <matrix-noun> }
    rule tag-type-phrase { [ <tag-noun> | <tag-adjective> ] <type-noun> }
    rule tag-types-phrase { [ <tag-noun> | <tag-adjective> ] <types-noun> }
    rule what-are-phrase { <what-pronoun> [ <are-verb> | <is-verb> ] }


    # LSA specific
    token analysis-noun { 'analysis' }
    token entries-noun { 'entries' }
    token indexing-noun { 'indexing' }
    token latent-adjective { 'latent' }
    token semantic-adjective { 'semantic' }
    token term-noun { 'term' }

    rule doc-term-mat { [ <document-noun> | <item-noun> ] [ <term-noun> | <word-noun> ] <matrix-noun> }
    rule ingest-directive { <ingest-verb> | <load-verb> | <use-verb> | <get-verb> }
    rule lsa-object { <lsa-phrase>? <object-noun> }
    rule lsa-phrase { <latent-adjective> <semantic-adjective> <analysis-noun> | 'lsa' | 'LSA' }
    rule lsi-phrase { <latent-adjective> <semantic-adjective> <indexing-noun> | 'lsi' | 'LSI' }
    rule matrix-entries { [ <doc-term-mat> | <matrix-noun> ]? <entries-noun> }
    rule the-outliers { <the-determiner> <outliers-noun> }

    # LSI specific
    token frequency-noun { 'frequency' }
    token global-adjective { 'global' }
    token inverse-adjective { 'inverse' }
    token local-adjective { 'local' }
    token normalization-noun { 'normalization' }
    token normalizer-noun { 'normalizer' }
    token normalizing-noun { 'normalizing' }

    rule global-function-phrase { <global-adjective> <term-noun>? <weight-noun>? <function-noun> }
    rule join-type-phrase { <join-verb>? <type-noun> }
    rule local-function-phrase { <local-adjective> <term-noun>? <weight-noun>? <function-noun> }
    rule normalizer-function-phrase { [ <normalizer-noun> | <normalizing-noun> | <normalization-noun> ] <term-noun>? <weight-noun>? <function-noun>? }

}