Git Product home page Git Product logo

dym's People

Contributors

kos59125 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dym's Issues

findSimilarName shouldn't filter on d== min(d)

Suppose I mistype "log", as in:

options(error = DYN::DYM)
logg(10)
## Error: could not find function "logg"
## Did you mean: ['log', 'log2', 'logb']

I think it would be useful for this to return log10, log1p as well. At least it should be possible to have these returned if I increase the threshold in findSimilarNames.

A better approach would be to order by increasing distance, and return the first 10 (or however many) that lie within the threshold. I suggest something like this:

findSimilarName <- function (x, names, threshold = 2, max_n = 10) 
{
    if (is.na(x)) {
        character(0)
    }
    else {
        names <- na.omit(names)
        d <- as.integer(adist(x, names))
        distance_data <- data.frame(
          names = names, 
          distance = d,
          stringsAsFactors = FALSE
        )[order(d), ]
        distance_data <- distance_data[distance_data$distance <= threshold, ]
        head(distance_data, max_n)$names
    }
}

# Example usage
x <- "logg"
names <- DYM:::getNames(x)

for(i in 0:4)
{
  message("i = ", i)
  print(findSimilarName(x, names, threshold = i))
}
## i = 0
## character(0)
## i = 1
## [1] "log"  "log2" "logb"
## i = 2
## [1] "log"   "log2"  "logb"  "lag"   "load"  "log10" "log1p"
## i = 3
##  [1] "log"   "log2"  "logb"  "lag"   "load"  "log10" "log1p" "aov"   "Arg"   "args" 
## i = 4
##  [1] "log"   "log2"  "logb"  "lag"   "load"  "log10" "log1p" "aov"   "Arg"   "args"

Options for DYM function

DYM should be take options for user's tuning. It looks better if we can write like:

options(error = DYM(option.a=1, option.b=2))

Generating non.meaningful error messages

> ()
 エラー:  予想外の ')' です  in "()"
 wrapup 中にエラーが起こりました: there is no package called ‘ エラー:  予想外の ')' です  in "()"
’

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.