Why does the annotation test environment of UIMA-Ruta count some annotations as True Positive and False Positiv - uima

I would like to evaluate my ruta script using the annotation test environment provided by the uima ruta plugin for eclipse. I've built a manually-annotated corpus. Some annotations are evaluated as true postives as well as false positives, which should not be possible per definition.
I have already checked, if there are minor differences between the true positives and false positives, but they are in fact identical (same offsets).
As an option I chose "partial match".
When I check the results.xmi, where I can see the true positives, false positives, and false negatives as annotations, the annotations in question have an error-feature; but there is no further information.
True Postives and False Positives as Annotations in the result.xmi
The annotations in question should actually be true positives.
Edit: I also noticed that when I specify only one type (i.e. one type of annotation) to be evaluated, everything is like it should be. The problem occurs only when more than one type is supposed to be evaluated.

Related

Iolang code works differently between in file and in relp

This is my code:
OperatorTable addOperator("xor", 11)
OperatorTable println
true xor := method(bool, if(bool, false, true))
false xor := method(bool, if(bool, true, false))
true xor(false)
true xor false
When I type it into relp, it works correctly. But, when I try to run it in file, true xor false works strangely.
That happens because the operator table code is parsed like the rest of your code, once. Meaning you'll want to have your operator table code in a separate file if you want to use it in the file you defined it in first. Then have a call like doFile("...") in the same file as your operator table stuff.
One thing to understand about Io, its parser does not have multiple stages it goes through beyond "rewriting operators" -- meaning, if the operators are in the table at the time the file is being parsed, it'll use those precedence levels to add parenthesis wherever needed according to those rules. However, if you're defining the precedence rules in the file you want them to be used in, it will not work because Io doesn't do a second parsing phase after you manipulate the operator table.
When we were building this feature, we talked about it, but opted to keep it simple because multiple phases required additional complexity.
The REPL works the way it does because each time you hit enter, it's like a new file -- it's a new string buffer with code in it that the VM will interpret within the running context, but parse it separately.
I hope this helps. For context, I was a developer of Io for years.

Is "true == !false" always true?

This was raised in the office today. With the various types of computing, various languages and various boolean types. Is the following always true
true == !false;
While there should be no language where your expression can directly be false, there are quite a number of languages where the related expression
someTrueValue == !false
does not hold true. C and its variants, for instance. And Lisp variants, to name just a few. In these languages, there is one false value (zero or nil), everything else is considered true. So, !false will yield one of these true values, which can be different from someTrueValue.
Assuming true and false are reserved keywords representing boolean values, it should always be true.
If the language happens to not reserve those keywords (ie: older versions of Python), you could always declare a variable with those names such that true == !false is false.
In addition to true and false being variables, ! has different meanings in many languages. Though I don't know any language which uses == for something other than (some sort of) equality, it could be user-defined.
Yes. It is because !false equals true, and true always equals true.
If there was ever a language where (true == !false)==false then the language would be inconsistent with Boolean logic ('inconsistent' is being used here both informally and in a formal sense within Boolean logic) and the result of this would be that it would be possible to derive inconsistent logical assertions (such as true == false, or false == true).
The final result of this would be that there would be no trustworthy logical framework underpinning any of the use of conditionals within the language rendering it useless.

Using units/components in Modelica based on a Boolean condition

Let's say I maybe want to import a component based on some condition, let's say a boolean variable. I've tried this, but it gives me an error message. For instance, consider the following code:
model myNewModel
parameter Boolean use_Something;
myLibrary.myComponent component[if use_Something then 1 else 0];
// In other words (pseudo):
// if use_Something then 'Import The Component' else 'Do Nothing At All';
end myNewModel;
This is, intuitively, a safe statement, and as long as the boolean variable is true, it'll work as intended. For some units, for instance the fluidports of the Modelica Standard Library, it also works with the [0] size. But as soon as I turn the variable to false, I encounter errors regarding the fact that many components are not compatible with "zero size". I've had this problem, for instance, with the MassFlowSources in the Modelica Standard Library. Is there a smooth/elegant way to work around this? Thanks in advance!
You can use conditional components in Modelica.
model myNewModel
parameter Boolean use_Something;
myLibrary.myComponent component if use_Something;
end myNewModel;
This component may then only be used in connect-statements. If the condition is false, these connections are ignored by the tool.

Why doesn't Array's == function return true for Array(1,2) == Array(1,2)?

In Programming in Scala the authors write that Scala's == function compares value equality instead of reference equality.
This works as expected on lists:
scala> List(1,2) == List(1,2)
res0: Boolean = true
It doesn't however work on arrays:
scala> Array(1,2) == Array(1,2)
res1: Boolean = false
The authors recommend to use the sameElements function instead:
scala> Array(1,2).sameElements(Array(1,2))
res2: Boolean = true
As an explanation they write:
While this may seem like an inconsistency, encouraging an explicit test of the equality of two mutable data structures is a conservative approach on the part of the language designers. In the long run, it should save you from unexpected results in your conditionals.
What does this mean? What kind of unexpected results are they talking about? What else could I expect from an array comparison than to return true if the arrays contain the same elements in the same position? Why does the equals function work on List but not on Array?
How can I make the equals function work on arrays?
It is true that the explanation offered in the book is questionable, but to be fair it was more believable when they wrote it. It's still true in 2.8, but we have to retrofit different reasoning because as you've noticed, all the other collections do element comparisons even if they're mutable.
A lot of blood had been shed trying to make Arrays seem like the rest of the collections, but this was a tremendously leaky abstraction and in the end it was impossible. It was determined, correctly I think, that we should go to the other extreme and supply native arrays the way they are, using implicit machinery to enhance their capabilities. Where this most noticeably falls down is toString and equals, because neither of them behaves in a reasonable fashion on Arrays, but we cannot intercept those calls with implicit conversions because they are defined on java.lang.Object. (Conversions only happen when an expression doesn't type check, and those always type check.)
So you can pick your explanation, but in the end arrays are treated fundamentally differently by the underlying architecture and there's no way to paper over that without paying a price somewhere. It's not a terrible situation, but it is something you have to be aware of.
This exact question has been voiced many times (by myself too, see Strange behaviour of the Array type ).
Note that it is ONLY the Array collection that does not support ==, all other collections do. The root cause is that Array IS the Java array.
It's all about referential transparency. The idea is, if two values are ==, it shouldn't matter which one you use for something. If you have two arrays with the same contents, it clearly matters which one you modify, so == returns false unless they are the same one.

Boolean true - positive 1 or negative 1?

I'm designing a language, and trying to decide whether true should be 0x01 or 0xFF. Obviously, all non-zero values will be converted to true, but I'm trying to decide on the exact internal representation.
What are the pros and cons for each choice?
It doesn't matter, as long as it satisfies the rules for the external representation.
I would take a hint from C here, where false is defined absolutely as 0, and true is defined as not false. This is an important distinction, when compared to an absolute value for true. Unless you have a type that only has two states, you have to account for all values within that value type, what is true, and what is false.
0 is false because the processor has a flag that is set when a register is set to zero.
No other flags are set on any other value (0x01, 0xff, etc) - but the zero flag is set to false when there's a non-zero value in the register.
So the answers here advocating defining 0 as false and anything else as true are correct.
If you want to "define" a default value for true, then 0x01 is better than most:
It represents the same number in every bit length and signedness
It only requires testing one bit if you want to know whether it's true, should the zero flag be unavailable, or costly to use
No need to worry about sign extension during conversion to other types
Logical and arithmetic expressions act the same on it
-Adam
Using -1 has one advantage in a weakly typed language -- if you mess up and use the bitwise and operator instead of the logical and operator, your condition will still evaluate correctly as long as one of the operands has been converted to the canonical boolean representation. This isn't true if the canonical representation is 1.
0xffffffff & 0x00000010 == 0x00000010 (true)
0xffffffff && 0x00000010 == 0xffffffff (true)
but
0x00000001 & 0x00000010 == 0x00000000 (false)
0x00000001 && 0x00000010 == 0xffffffff (true)
Why are you choosing that non-zero values are true? In Ada true is TRUE and false is FALSE. There is no implicit type conversion to and from BOOLEAN.
IMO, if you want to stick with false=0x00, you should use 0x01. 0xFF is usually:
a sign that some operation overflowed
or
an error marker
And in both cases, it probably means false. Hence the *nix return value convention from executables, that true=0x00, and any non-zero value is false.
-1 is longer to type than 1...
In the end it doesn't matter since 0 is false and anything else is true, and you will never compare to the exact representation of true.
Edit, for those down voting, please explain why. This answer is essentially the same as the one currently rated at +19. So that is 21 votes difference for what is the same basic answer.
If it is because of the -1 comment, it is true, the person who actually defines "true" (eg: the compiler writer) is going to have to use -1 instead of 1, assuming they chose to use an exact representation. -1 is going to take longer to type than 1, and the end result will be the same. The statement is silly, it was meant to be silly, because there is no real difference between the two (1 or -1).
If you are going to mark something down at least provide a rationale for it.
0xff is an odd choice since it has an implicit assumption that 8 bits is your minimum storage unit. But it's not that uncommon to want to store boolean values more compactly than that.
Perhaps you want to rephrase by thinking about whether boolean operators produce something that is just one 0 or 1 bit (which works regardless of sign extension), or is all-zeroes or all-ones (and depends on sign extension of signed two's-complement quantities to maintain all-ones at any length).
I think your life is simpler with 0 and 1.
The pros are none, and the cons are none, too. As long as you provide an automatic conversion from integer to boolean, it will be arbitrary, so it really doesn't matter which numbers you choose.
On the other hand, if you didn't allow this automatic conversion you'd have a pro: you wouldn't have some entirely arbitrary rule in your language. You wouldn't have (7 - 4 - 3) == false, or 3 * 4 + 17 == "Hello", or "Hi mom!" == Complex(7, -2).
I think the C method is the way to go. 0 means false, anything else means true. If you go with another mapping for true, then you are left with the problem of having indeterminate values - that are neither true nor false.
If this is language that you'll be compiling for a specific instruction set that has special support for a particular representation, then I'd let that guide you. But absent any additional information, for an 'standard' internal representation, I'd go with -1 (all 1's in binary). This value extends well to whatever size boolean you want (single bit, 8-bit, 16, etc), and if you break up a "TRUE" or a "FALSE" into a smaller "TRUE" or "FALSE", its still the same. (where if you broke a 16 bit TRUE=0x0001 you'd get a FALSE=0x00 and a TRUE=0x01).
Design the language so that 0 is false and non-zero is true. There is no need to "convert" anything, and thinking "non-zero" instead of some specific value will help you write the code properly.
If you have built-in symbols like "True" then go ahead and pick a value, but always think "non-zero is true" instead of "0x01 is true".
Whatever you do, once you select your values don't change them. In FORTH-77, true and false were defined as 1 and 0. Then, FORTH-83 redefined them as -1 and 0. There were a not few (well ok, only a few, this is FORTH we are talking about) problems caused by this.