> Finally, your size() function should return a tuple with one element
> instead of a scalar. You should also have a length function, like this:
> Base.length(s::Ngram) = length(s.seq) - s.n + 1
> Base.size(s::Ngram) = (length(s),)
>
Note that length(s) is automatically defined if you supply a
Le vendredi 06 février 2015 à 03:48 -0800, Ivar Nesje a écrit :
> Please don't tell him to use +1 and -1 to manipulate UTF8String
> indexes. Use nextind and prevind.
Indeed, shame on me, for somebody who's trying to forbid indexing
strings with integers...
So, if you want to support strings other
Please don't tell him to use +1 and -1 to manipulate UTF8String indexes. Use
nextind and prevind.
Le jeudi 05 février 2015 à 23:58 -0800, Wai Yip Tung a écrit :
> The idea of Ngram is that it is a view of N string of length k without
> using k times as much memory. I would like to preform operation the
> set of Ngram string, let's say unique(). In those cases I expect it to
> be treat as 1 dime
The idea of Ngram is that it is a view of N string of length k without
using k times as much memory. I would like to preform operation the set of
Ngram string, let's say unique(). In those cases I expect it to be treat as
1 dimension Array of String.
I am making some progress with similar defin
Le mercredi 04 février 2015 à 23:11 -0800, Wai Yip Tung a écrit :
> I have successfully defined a custom array Ngram.
>
>
>
> type Ngram <: AbstractArray{ASCIIString,1}
> seq::ASCIIString
> n::Int
> end
>
>
> function getindex(s::Ngram, i::Int)
> s.seq[i:i+s.n-1]
> end
>
>
> func
I have successfully defined a custom array Ngram.
type Ngram <: AbstractArray{ASCIIString,1}
seq::ASCIIString
n::Int
end
function getindex(s::Ngram, i::Int)
s.seq[i:i+s.n-1]
end
function Base.size(s::Ngram)
length(s.seq) - s.n + 1
end
It works as I expected. For example
In [21