Has anyone tried this library out? I cannot get it to work. For example, the spelling suggestions should work as follows.
But I am getting an empty list back.
I first got an exception saying
C:\Program Files (x86)\Common Files\microsoft
shared\DevServer\10.0\en-us.dic
is missing so I downloaded it from the web. The file I got has a list of thousands of english words and I even tried words from what it in the file and still no luck.
He is some code I tried.
Spelling s = new Spelling();
ArrayList items;
s.MaxSuggestions = 5;
s.SuggestionMode = Spelling.SuggestionEnum.PhoneticNearMiss;
s.Suggest(str);
items = s.Suggestions;
s.SuggestionMode = Spelling.SuggestionEnum.NearMiss;
s.Suggest(str);
items = s.Suggestions;
s.SuggestionMode = Spelling.SuggestionEnum.Phonetic;
s.Suggest(str);
items = s.Suggestions;
The Suggest method is supposed to get suggestions for 'str' and populate the Suggestions property. I am always getting 0 suggestions. I tried all three suggestion types that the library supports to see if that does anything as you can see, but that does not work either.
Even simple calls such as
s.TestWord("book")
give back "false". I think it is not able to use the dictionary file but not sure what else to do about it.
That is what it was, the dic file was not compatible. I just used the one that comes with when you download NetSpell and it works like a charm.
By the way, I switche to NHunspell and I like it much better than NetSpell. Easier to use and better suggestions.
http://www.crawler-lib.net/nhunspell
Related
Thanks for someone who might be able to help me further, as I can't find an answer in the www right now. I actually program VB.net, but since this language is now dissolved and not further developed, I want to switch to C#. I am getting on well, because a lot of things are similar. There is only one method where I am stuck.
In vb.net I always liked to use the method:
mystring.split(seperator)(part)
to get a certain string from a CSV line and work with it. How does this work in C#? I know that I can load everything into an array, but I don't want to do that in this case. A simple split and the number of the element is enough. Can someone help me?
Seems like the same split method is what you need? It returns an array which you could store or just access directly. The difference being in C# you use [index] instead. So something like this:
string myFile = File.ReadAllText("myfile.txt");
string firstLine = myFile.Split("\r\n")[0];
I have a CSV file with 412.000 strings in that I would like to pre-store locally so that I can deploy to Android and iOS. The game must then be able to look through these strings to check if there's a match based on user input.
The only viable solution that I can see would be SQLite. I haven't come across a very good SQLite solution for Unity yet.
Is there a built-in solution in Unity that I am overlooking?
The solution has to work locally. No HTTP calls.
400,000 strings is absolutely trivial.
Just put them in a dictionary (list, whatever is relevant and that you prefer).
It's a total non-issue.
It's likely you would just load them from a text file, easy as pie.
public TextAsset theTextFile;
(Just drag to the link in the Inspector, like any texture or similar.)
you can then very easily read that file as, say, JSON. (Just use JsonUtility. You can find numerous examples of this in SO and elsewhere.) For example,
Blah bb = JsonUtility.FromJson< Blah >(ta.text);
yourDict = bb.fieldname.ToDictionary(i => i.tag, i => i);
Note that you mention "memory" and so on. It's totally irrelevant, the data you are talking about is the fraction of the size of any tiny image - ! , it's a non-issue, you don't have to think about it. The hardware/software system will handle it.
P.S. ...
If you literally want to use csv, it's totally easy. I suggest you ask a new question giving the details of your file and so on, so you can get an exact answer.
Note that you'd just use a HashSet rather than a Dictionary. It's even easier.
It's just something like:
var wordList = theTextFile.text.Split('\n');
You can google many examples!
https://stackoverflow.com/a/9791488/294884
http://answers.unity.com/answers/397537/view.html
I've been trying out the most of the Enviroment.SpecialFolder enumeration, but I think there isn't any way of what I'd like to accomplish with the enumeration only. Using the string.Substring() method brought me the farest, yet.
I try to get just the system partition path, where windows is actually installed. On machine A it might be C:\, on machine B it might be D:\.
The most sufficent solution, I found so far was
var path = Environment.GetFolderPath(Environment.SpecialFolder.Windows)
.Substring(0, 3);
Is there a better way to do this? Thanks.
To get the drive, use Path.GetPathRoot. See http://msdn.microsoft.com/en-us/library/system.io.path.getpathroot.aspx
var root = Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.Windows));
If you need "disk where Environment.SpecialFolder.Windows" your sample is ok.
You may want to use Path.GetPathRoot instead of Susbstring...
Note that you probably should not write anything to the root drive yourself (if your program is designed to behave nice).
When attempting to solve the problem
How many seven-element subsets (not repeatable) are there in a set of nine elements ?
I tried
IEnumerable<string> NineSet =new string[] {"a","b","c","d","e","f","g","h","i"};
var SevenSet =
from first in NineSet
from second in NineSet
where first.CompareTo(second)< 0 && first.Count() + second.Count()==7
select new { first, second };
What is the problem that prevents me from attempting to use first.Count() and second.Count()? I did not check whether it is the best solution for the problem.
As already stated, what you have written down will lead you to nowhere. This is a question of combinatorics. AFAIK there is nothing pre-made in the .NET framework to solve for you combinatorics problems, hence you will have to implement the correct algorithm. If you get stuck, there are solutions out there, e.g. http://www.codeproject.com/KB/recipes/Combinatorics.aspx, where you can look at the source to see what you need to do.
first and second are strings, so you'll count their characters (this compiles, but intellisence hides it).
You're looking for something like NineSet.Count(first.Equals)
Well...
You haven't shown the error message, so it's hard to know what's wrong
Every element is of length exactly one, so I'm not sure what you're expecting to happen
As you know that first and second are strings, why aren't you using first.Length and second.Length?
As a side issue, I don't think this approach is going to solve the problem for you, I'm afraid...
I'm messing around with some windows functions using p/invoke. Occasionally, I get an error code that is not ERROR_SUCCESS (such an odd name).
Is there a way to look these up within the program? Forexample, if I get error 1017. Can I tell the user
The system has attempted to load or
restore a file into the registry, but
the specified file is not in a
registry file format.
(ERROR_NOT_REGISTRY_FILE: 0x3F9)
Instead of
Error Code: 1017
I'm not sure if there's a niifty .NET wrapper, but you could call the FormatMessage API using P/Invoke.
See this answer for how it would normally be called from native code. Though the question refers to grabbing error codes from HRESULTs, the answer also applies for retreiving codes from the regular OS error codes coming from GetLastError/GetLastWin32Error).
EDIT: Thanks Malfist for pointing me to pinvoke.net, which includes alternative, managed API:
using System.ComponentModel;
string errorMessage = new Win32Exception(Marshal.GetLastWin32Error()).Message;
Console.WriteLine(errorMessage);
You could take the defines from winerror.h at Rensselaer Polytechnic Institute, and put them into an Enum:
public enum Win32ErrorCode : long
{
ERROR_SUCCESS = 0L,
NO_ERROR = 0L,
ERROR_INVALID_FUNCTION = 1L,
ERROR_FILE_NOT_FOUND = 2L,
ERROR_PATH_NOT_FOUND = 3L,
ERROR_TOO_MANY_OPEN_FILES = 4L,
ERROR_ACCESS_DENIED = 5L,
etc.
}
Then if your error code is in a variable error_code you would use :
Enum.GetName(typeof(Win32ErrorCode), error_code);
I landed on this page while in search of a managed alternative to calling FormatMessage through P/Invoke.
As others have said, there is no way to get those capitalized, underscored names, short of looking them up in winerror.h, which I have seen reproduced online in various places where I landed in the course of searching for information about resolving specific status codes. A quick Google search, for winerror.h, itself, uncovered a page, at Rensselaer Polytechnic Instutute, where someone has helpfully extracted the #define statements from it.
Looking at it gave me an idea; I think there may be a way to get there, working from the source code of winerror.h, which I have, as part of the Windows Platform SDK that ships with every recent version of Microsoft Visual Studio.
Right now, I am in the middle of sorting out a pressing issue in the .NET assembly that brought me to this page. Then, I'll see what I can cobble together; this kind of challenge is right up my alley, and somebody threw down a gauntlet.
Yes there's a function that does that but I don't remember what it is. In the mean time, you can use the error lookup tool (Tools->Error Lookup) to see what a particular code means from within Visual Studio.