Project

General

Profile

Bug #104

Misprints suggestions: Z --> ZZ

Added by Anna Maria Bigatti about 12 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Parser/Interpreter
Target version:
Start date:
15 Mar 2012
Due date:
% Done:

100%

Estimated time:
3.00 h
Spent time:

Description

CoCoA-5 is very helpful with suggestions on misprints.
Is it possible to improve this case? i.e. suggest "ZZ" as well?

Use Z/(5)[x,y,z,w];
ERROR: Cannot find a variable named "Z" in scope.
A similarly named variable (that you might need to import) is: "z" 
Use Z/(5)[x,y,z,w];
    ^


Related issues

Related to CoCoA-5 - Bug #321: interpreter proposes no near misses for "bin"Closed2013-02-25

History

#1 Updated by John Abbott about 12 years ago

Are you asking to add
  1. special checks for the names "Z" and "Q" in a context where a ring is to be expected?
  2. special checks for "Z" and "Q" in any context?
  3. some extra checks for single letter names (in any context)?

JAA thinks (1) could be difficult. (2) should be easy. (3) requires clarification.

#2 Updated by Anna Maria Bigatti about 10 years ago

  • Target version set to CoCoA-5.1.0 Easter14

#3 Updated by John Abbott about 10 years ago

  • Target version changed from CoCoA-5.1.0 Easter14 to CoCoA-5.1.1 Seoul14

#4 Updated by Anna Maria Bigatti over 9 years ago

Some tests:
ZZ is suggested when giving ZZZ, or zz, so it is indeed in the list.
Maybe the problem is just that Z is too short.

The function doing the job is collectSimilarlyNamedIdentifiers in Interpreter.C (not a trivial function...)

#5 Updated by Anna Maria Bigatti over 9 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

#6 Updated by Anna Maria Bigatti over 9 years ago

some more tests (just to understand what the algorithm is doing).

/**/ AA := 3;

/**/ A;    --> nothing
/**/ AAa;  --> "AA" 
/**/ Af;   --> "AA", "DF", "LF", "NF" 
/**/ AaB;  --> "AA" 

#7 Updated by John Abbott over 9 years ago

Another important function is maximumDistanceForSimilarIdentifiers (Interpreter.C:921) which says how many "changes" (ignoring case) are allowed between "similar" identifiers. It sets the value to 0 for identifiers of length 1. We can try increasing it to 1 for identifiers of length 1 -- I presume the empty string is not allowed as an identifier 8-0

#8 Updated by John Abbott over 9 years ago

  • % Done changed from 10 to 20

I have just tried increasing to 1 the max distance for length 1 identifiers. Not sure whether I like the result. Here is what I obtained in a couple of simple tests (in a fresh CoCoA-5 session):

>>> Use Z/(5)[x,y,z,w];
--> ERROR: Cannot find a variable named "Z" in scope.
Similarly named variables (that you might need to import) are: "R", "ZZ", "x", "y", "z" 
--> Use Z/(5)[x,y,z,w];
-->     ^

and somewhat predictably

>>> use Q[a,b,c];
--> ERROR: Cannot find a variable named "Q" in scope.
Similarly named variables (that you might need to import) are: "QQ", "QR", "R", "x", "y", "z" 
--> use Q[a,b,c];
-->     ^

I can imagine that in a non-fresh CoCoA-5 session there could easily be many more single letter identifiers in the list of proposed names e.g. A, f, F, I, J etc.

#9 Updated by Anna Maria Bigatti over 9 years ago

  • Status changed from In Progress to Feedback
  • Assignee set to John Abbott
  • % Done changed from 20 to 80

After a last look at the code I agreed with John's choice (2) in mesg 1: just to add the very special cases for "Z" and "Q" and ignore the other single letters.

#10 Updated by Anna Maria Bigatti over 9 years ago

  • Estimated time set to 3.00 h

#11 Updated by John Abbott over 9 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 80 to 100

Also available in: Atom PDF