Definition for BLOCK_LIST / BLOCK_IT - tesseract

I am using tesseract ocr. I am not able to find the definition of BLOCK_LIST or BLOCK_IT. May I know where the definition of these classes are present.

class BLOCK_LIST and BLOCK_IT are generated by a macro named ELISTIZEH , it is defined in ccstruct/elst.h

Related

Scala macro annotations. Is there a way to get a typed AST of class when using macro annotation?

I use macro-notation to analyze a code inside a class, but the AST inside a marked class is not typed and TermNames/TypeNames is not expanded.
In simple cases I can use Context.typecheck(classAst) and obtain typed AST. But for more complex classes, an error occurs because the typechecker does not yet know the definition of the outer classes that are used inside the current class.

Can I run a Scala macro automatically when I extend a given type?

Currently, I use a Scala macro annotation to automatically generate some code into a Scala object. It works like this:
#constants
object PopoverCommands extends Constants { … }
I find it somewhat redundant to have to extend Constants and to annotate PopoverCommands with #constants. I know the macro annotation can insert the extends Constants part. My question goes the other way round: is there any way I can run some macro code (e.g. simulate the presence of #constants) by simply extending a type (here, Constants)?
No, this isn't currently possible.

Why does Array.fill take an implicit scala.reflect.ClassManifest?

So I'm playing with writing a battlecode player in Scala. In battlecode certain classes are disallowed and there is a runtime exception if you ever try to access them. When I use the Array.fill function I get a message from the battlecode server saying [java] Illegal class: scala/reflect/Manifest$. This is the offending line:
val g_score = Array.fill[Int](rc.getMapWidth(), rc.getMapHeight())(0)
The method takes an implicit ClassManifest argument which has the following documentation:
A ClassManifest[T] is an opaque descriptor for type T. It is used by the compiler
to preserve information necessary for instantiating Arrays in those cases where
the element type is unknown at compile time.
But I do know the type of the array elements at compile time, as shown above I explicitly state that they will be Int. Is there a way to avoid this? To workaround I've written my own version of Array.fill. This seems like a hack. As an aside, does Scala have real 2D arrays? Array.fill seems to return an Array[Array[T]] which is the only way I found to write my own. This also seems inelegant.
Edit: Using Scala 2.9.1
For background information, see this related question: What is a Manifest in Scala and when do you need it?. In this answer, you will find an explanation why manifests are needed for arrays.
In short: Although the JVM uses type erasure, arrays are an exception and need a manifest. Since you could compile your code, that manifest was found (manifests are always available for proper types). Your error occurs at runtime.
I don't know the details of the battlecode server, but there are two possibilities: Either you are running your compiled classes with a binary incompatible version of Scala (difference in major version, e.g. compiled with Scala 2.9 and server uses 2.10). Or the server doesn't even have the scala-library.jar on its class path.
As said in the comment, manifests are deprecated in Scala 2.10 and replaced by ClassTag.
EDIT: So it seems the class loader is artificially restricting the allowed classes. My suggestion would be: Add a helper Java class. You can easily mix Java and Scala code. If it's just about the Int-Array instantiation, you could provide something like:
public static class Helper {
public static int[][] makeArray(int d1, int d2) { return new int[d1][d2](); }
}
(hope that's valid java code, a bit rusty)
Also, have you tried to create the outer array with new Array[Array[Int]](d1), and then iterate to create the inner arrays?

Where is subsetOf in scala collections?

I'm at a loss on this one...
Looking at a Set in Scala collections, I see that there is a method called subsetOf. But when I try to find where it is in the actual .scala source code (I've looked in Set.scala, GenSet.scala, SetLike.scala etc...) I can't find it!!!
Which trait actually defines that method? Or am I missing something?
If you click on function in scaladoc, you may see where is it defined:
The scala API specifies:
Definition Classes: GenSetLike
When you're looking at the API page, click the method entry to expand it. You'll see more information, including the "Definition Classes".
If you look at the source for GenSetLike.scala, you'll see it:
def subsetOf(that: GenSet[A]): Boolean = this forall that

OCaml interface vs. signature?

I'm a bit confused about interfaces vs. signatures in OCaml.
From what I've read, interfaces (the .mli files) are what govern what values can be used/called by the other programs. Signature files look like they're exactly the same, except that they name it, so that you can create different implementations of the interface.
For example, if I want to create a module that is similar to a set in Java:
I'd have something like this:
the set.mli file:
type 'a set
val is_empty : 'a set -> bool
val ....
etc.
The signature file (setType.ml)
module type Set = sig
type 'a set
val is_empty : 'a set -> bool
val ...
etc.
end
and then an implementation would be another .ml file, such as SpecialSet.ml, which includes a struct that defines all the values and what they do.
module SpecialSet : Set
struct
...
I'm a bit confused as to what exactly the "signature" does, and what purpose it serves. Isn't it acting like a sort of interface? Why is both the .mli and .ml needed? The only difference in lines I see is that it names the module.
Am I misunderstanding this, or is there something else going on here?
OCaml's module system is tied into separate compilation (the pairs of .ml and .mli files). So each .ml file implicitly defines a module, each .mli file defines a signature, and if there is a corresponding .ml file that signature is applied to that module.
It is useful to have an explicit syntax to manipulate modules and interfaces to one's liking inside a .ml or .mli file. This allows signature constraints, as in S with type t = M.t.
Not least is the possibility it gives to define functors, modules parameterized by one or several modules: module F (X : S) = struct ... end. All these would be impossible if the only way to define a module or signature was as a file.
I am not sure how that answers your question, but I think the answer to your question is probably "yes, it is as simple as you think, and the system of having .mli files and explicit signatures inside files is redundant on your example. Manipulating modules and signatures inside a file allows more complicated tricks in addition to these simple things".
This question is old but maybe this is useful to someone:
A file named a.ml appears as a module A in the program...
The interface of the module a.ml can be written in file named a.mli
slide link
This is from the OCaml MOOC from Université Paris Diderot.