Is there any tag in hunspell to declare the current word as wrong but all it's tags to be valid?
In the following example, how do I declare the original word "party" as a wrong word while it's plural form "parties" to be correct?
party/S
SFX S Y 9
SFX S y ies [^aeiou]y
SFX S 0 s [aeiou]y
SFX S 0 es [sxz]
SFX S 0 es [cs]h
SFX S 0 s [^cs]h
SFX S 0 s [ae]u
SFX S 0 x [ae]u
SFX S 0 s [^ae]u
SFX S 0 s [^hsuxyz]
I can use No-suggest flag. But that will accept the "party" word as correct one and will not underline it as wrong. The only difference is that the word will not be suggested. I want to treat it as wrong.
I declared a new tag
NEEDAFFIX x
and then used it in the dictionary...
party/Sx
Related
I am trying to write an efficient subroutine in Fortran to find the list of all duplicate vertices in an array. The tolerance (fixed using parameter paraEps) corresponds to the radius around each point in which I look for the duplicate points. The vertices and defined for Finite Element Analysis and the range of each component will depend on the 3D geometry on which the methods will be applied (I can expect that values of the components could be varied in [-10^6,10^6] with a precision of 10^-6.
Currently the following code is running on around 150k vertices but it will be used on array of 1-3M vertices.
Example:
A array of vertices. Here I just use some small list of nodes. In my case, nodes are in a 3D space with no specific distribution.
verticesArray =
[ 0 0 0,
0 1 0
1 0 0
1 0 0
1 1 1
0 1 0
1 2 3
1 2 3
0 1.0001 0
0 1.1 0
1 2 4]
The result list (0 means the vertice has no duplicate) with a tolerance of 10^-3.
list = [ 0 1 2 2 0 1 3 3 1 0 0]
I have written a first version that works fine but remains slow especially the number of vertices is large.
Notice that startItem is an integer I can specify for starting the search not from the beginning of the array.
MWE:
module test
implicit none
contains
subroutine get_dup_nodes(nbNodes,dimP,arrayIn,nbDupNodes)
!
integer,intent(in) :: nbNodes,dimP ! number of nodes and dimension
double precision,dimension(:,:),intent(in) :: arrayIn ! list of coordinates
!
integer,intent(out) :: nbDupNodes
!
double precision,dimension(dimP) :: coorNode
integer,dimension(:),allocatable :: listDup !list of duplicates
logical :: currUnique
double precision,allocatable :: distVal
integer :: itN,itM,itF,minCurrIt,currIt,nbTmp,sizeR,startItemVal
!
double precision,parameter :: paraEps=1e-3
!
!initialize variables
allocate(listDup(nbNodes))
listDup=0
nbDupNodes=0
itF=0
distVal=1.
!
do itN=1,nbNodes
!coordinate current node
coorNode=arrayIn(itN,:)
currUnique=.true.
!search for current nodes coordinates in the list of nodes
if (listDup(itN).eq.0) then
do itM=itN+1,nbNodes
! compute distance to current point
distVal = NORM2(coorNode-arrayIn(itM,:))
! if the distance is to small then duplicate
if (distVal.le.paraEps) then
!first time it is a duplicate
if (currUnique) then
currUnique=.false.
nbDupNodes=nbDupNodes+1
listDup(itN)=nbDupNodes
endif
listDup(itM)=nbDupNodes
endif
enddo
endif
enddo
print *,listDup
end subroutine get_dup_nodes
end module test
program testb
use test
implicit none
double precision,dimension(33) :: valTmp
double precision,dimension(11,3) :: verticesArray
integer :: nbd
integer :: i,j,k
valTmp = (/ 0.,0.,0.,0.,1.,0.,1.,0.,0.,1.,0.,0.,1.,1.,1.,0.,1.,0.,1.,2.,3.,1.,2.,3.,0.,1.0001,0.,0.,1.1,0.,1.,2.,4. /)
k=1
do i=1,11
do j=1,3
verticesArray(i,j)=ValTmp(k)
k=k+1
enddo
print *,verticesArray(i,:)
enddo
call get_dup_nodes(11,3,verticesArray,nbd)
end program testb
Additional request: if you have references of books about such kind of algorithm, it could be useful.
I want to use the nat type in Isabelle but I want to overload some existing definitions like for example addition. I wrote the following code:
theory Prueba
imports Main HOL
begin
primrec suma::"nat ⇒ nat ⇒ nat" where
"suma 0 n = 0" |
"suma (Suc x) n = 0"
no_notation suma (infix "+" 65)
value "2 + (1 :: nat)"
I tried to overload addition with a new definition that always outputs 0. However when I evaluate 2 + (1 :: nat) I get "Suc (Suc (Suc 0))" :: "nat", which means Isabelle is still using the plus definition from Nat. How can I get it to use my new definition of +?
Thank you
Your must use no_notation to remove the default plus-syntax which comes from the plus type class of the Groups theory.
no_notation Groups.plus_class.plus (infixl "+" 65)
Then you can use
notation suma (infixl "+" 65)
to add your own syntax.
(I have never tried to override such basic parts of the definitions. I guess it might lead to strange situations – especially for other people trying to work with your theory afterwards.)
Hi I am working on an assembly, technically HLA(High Level Assembly) assignment and I am a bug that I need help with. Here is the assignment: Write an HLA Assembly language program that implements a function which correctly identifies whether all the parameters are different, returning either 0 or 1 in EAX depending on whether this condition has been met. This function should have the following signature:
procedure allDifferent( x: int16; y : int16; z : int16 ); #nodisplay; #noframe;
Shown below is a sample program dialogue.
Feed Me X: 205
Feed Me Y: 170
Feed Me Z: 91
allDifferent returns true!
Feed Me X: 0
Feed Me Y: 0
Feed Me Z: 0
allDifferent returns false!
Feed Me X: 121
Feed Me Y: 121
Feed Me Z: 121
allDifferent returns false!
Here is the code I have. My problem is that regardless of what numbers I put in, it always returns "allDifferent returns false!" Thanks you for the help.
program allDifferent;
#include( "stdlib.hhf" );
static
iDataValue1 : int16 := 0;
iDataValue2 : int16 := 0;
iDataValue3 : int16 := 0;
iDataValue4 : int16 := 0;
procedure allDiff( x: int16; y : int16; z : int16 ); #nodisplay; #noframe;
static
returnAddress : dword;
temp : int16;
begin allDiff;
pop(returnAddress);
pop(z);
pop(y);
pop(x);
pop(temp);
push(returnAddress);
push(AX);
push(BX);
mov(x, AX);
cmp(y, AX);
je xyequal;
jmp notequal;
xyequal:
mov(y, BX);
cmp(z, BX);
je equal;
jmp notequal;
equal:
mov(0, EAX);
jmp ExitSequence;
notequal:
mov(1, EAX);
jmp ExitSequence;
ExitSequence:
pop(BX);
pop(AX);
ret();
end allDiff;
begin allDifferent;
stdout.put( "Gimme a X:" );
stdin.get( iDataValue1 );
stdout.put("Gimme a Y:");
stdin.get(iDataValue2);
stdout.put("Gimme a Z:");
stdin.get(iDataValue3);
push( iDataValue1 );
push( iDataValue2 );
push( iDataValue3 );
push( iDataValue4 );
call allDiff;
cmp(EAX, 1);
je ISDIFFERENT;
jmp NOTDIFFERENT;
ISDIFFERENT:
stdout.put("allDifferent retursn true",nl);
jmp EndProgram;
NOTDIFFERENT:
stdout.put("allDifferent retursn false",nl);
jmp EndProgram;
stdout.newln();
EndProgram:
end allDifferent;
notequal:
mov(1, EAX); <<- good.
jmp ExitSequence;
:
ExitSequence:
pop(BX);
pop(AX); <<- not so good.
ret();
Have a close look at what's happening to AX in the above sequence. Even though you set it to something within the code, you overwrite that value with the pop instruction, reverting AX to whatever it was when you entered the function.
Assembler functions should generally preserve and restore registers that may be being used by the callers, but not when you want to use that register to return some useful piece of information.
In addition, your parameters are not being treated correctly. You push them in the order {p1, p2, p3, junk} (not sure why you have a fourth parameter since you don't use it for anything).
But, within the function, you pop in the order {x, y, z, temp}. Now, because the stack is a LIFO (last in, first out) structure, the mappings will be:
junk -> x
p3 -> y
p2 -> z
p1 -> temp
That means the x variable will be set to some arbitrary value rather than one of the "real" parameters you passed in.
If you're not going to use that fourth parameter, I'd suggest getting rid of it. If you do want to use it at some point, you'll need to correlate your push and pop operations so you get the correct values.
As an aside, you could probably also make your code a lot cleaner in a couple of ways.
First, there's no real need to use (or save/restore) BX since AX is used locally (in a small mov/cmp block). You could use AX both for the xy check and the yz check.
Second, you could get rid of quite a few of the jumps that aren't actually needed. The pseudo-code for your algorithm can boil down to a very simple:
if x and y are same, go to NOTDIFF.
if y and z are same, go to NOTDIFF.
DIFF:
set AX to 1
go to END
NOTDIFF:
set AX to 0
END:
return
Is it either possible to get the size of a function in bytes to see if it matches another function similar to C++ sizeof operator, or evaluate two functions some other way to see if they are both equal without actually knowing what the function/s are? Example:
local function equals(func1, func2)
-- check them and return true if equal
end
If this is not possible just say and that will satisfy my answer!
Thank you!
EDIT: The body of one function is what I need to check to see if it is the same as another function's body. The reference in memory will be different so I cannot use "==" but the function's reference name can be different.
Using == for functions only checks if they reference to the same function, which is not what you expected.
This task is rather difficult, if not impossible at all. For really simple cases, here's an idea:
function f(x) return x + 1 end
local g = function(y) return y + 1 end
f and g are two function that are equal by your definition. Assuming the file is t.lua, run:
luac -l t.lua
The output is:
main <t.lua:0,0> (4 instructions at 00000000003081c0)
0+ params, 2 slots, 1 upvalue, 1 local, 1 constant, 2 functions
1 [1] CLOSURE 0 0 ; 0000000000308330
2 [1] SETTABUP 0 -1 0 ; _ENV "f"
3 [2] CLOSURE 0 1 ; 0000000000308dc0
4 [2] RETURN 0 1
function <t.lua:1,1> (3 instructions at 0000000000308330)
1 param, 2 slots, 0 upvalues, 1 local, 1 constant, 0 functions
1 [1] ADD 1 0 -1 ; - 1
2 [1] RETURN 1 2
3 [1] RETURN 0 1
function <t.lua:2,2> (3 instructions at 0000000000308dc0)
1 param, 2 slots, 0 upvalues, 1 local, 1 constant, 0 functions
1 [2] ADD 1 0 -1 ; - 1
2 [2] RETURN 1 2
3 [2] RETURN 0 1
As you can see, the two functions have the same instructions in the virtual machine.
Will comparing the bytecode do?
local function equals(func1, func2)
return string.dump(func1) == string.dump(func2)
end
Surely, there would be some cases were the above would fail. For instance:
local function f1 (...)
local a = print
a(...)
end
local function f2 (...)
print(...)
end
local function equals (f1, f2)
return string.dump(f1) == string.dump(f2)
end
print(equals(f1,f2)) --> false
Both functions do the same thing, but they generate different bytecode. Maybe if you state what you're trying to achive, a better solution than function comparison can be provided.
In this .obj file:
o sometriangle
v 1 0 0
v 0 1 0
v 0 0 1
f 1 2 3
o somesquare
v 5 0 0
v 5 5 0
v 0 5 0
v 0 0 0
f 1 2 3 # HERE
f 1 3 4 # AND HERE
Do the marked lines refer to the vertices within their containing object, or are vertex numbers global?
The OBJ specification states
For all elements, reference numbers are used to identify geometric
vertices, texture vertices, vertex normals, and parameter space
vertices.
Each of these types of vertices is numbered separately, starting with
1. This means that the first geometric vertex in the file is 1, the second is 2, and so on. The first texture vertex in the file is 1, the
second is 2, and so on. The numbering continues sequentially
throughout the entire file. Frequently, files have multiple lists of
vertex data. This numbering sequence continues even when vertex data
is separated by other data.
So this means that the vertices are indeed numbered globally, at least within the same file.