What does lexicographically mean? [closed] - lexicographic

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I saw a program in codeforces where it says, "Now Petya wants to compare those two strings lexicographically."
I didn't understand it. What does lexicographically mean?

I'm not sure if this is more of a stackoverflow question or not, but I could be wrong. . . Based on your question and its usage I would prefer a breakdown of the word "lexicographically".
The root appears to be "lexicon", which we can see by this reference the definition is:
"a book containing an alphabetical arrangement of the words in a language and their definitions"
OR
"the vocabulary of a language, an individual speaker or group of speakers, or a subject"
OR (more related to computers)
"the total stock of morphemes in a language"
In this pdf the author says,
"The lexicon of a computer language is its total inventory of words and symbols."
Next, we want to look at the word "lexicography", this is the next layer to our process of building the word up from the root. First, let us look at the general definition. According to Merriam-Webster in this reference we see that lexicography is defined as such:
"the editing or making of a dictionary"
OR
"the principles and practices of dictionary making"
In this reference regarding Computation Lexicography the author states, "Computational Lexicology is the use of computers in the study of the lexicon. It has been more narrowly described by others (Amsler, 1980) as the use of computers in the study of machine-readable dictionaries."
The next-to-last step is to look at the word without its description of the action occurring, that would be "lexicographic", as in lexicographic order. In this reference we see, "In mathematics, the lexicographic or lexicographical order (also known as lexical order, or dictionary order) is a generalization of the alphabetical order of the dictionaries to sequences of ordered symbols or, more generally, of elements of a totally ordered set."
Lastly, we can see that the word is an adverb since in the example sentence it is describing the action that is occurring - also we see the use of "-ly" at the end of the word.
It would appear that Petya would like to compare the two strings alphabetically and with regard to their potentially symbolic, or definitive, meaning within the dictionary of lexicons from which they exist.
A fun little analysis project that took me on.

Related

Perl Split Operator [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 months ago.
Improve this question
I have a large text file of records each beginning with 22-. I want to read in the file and split it up into an array with one record per element. Looks like I will lose the 22- at the beginning of each element. Is there a way to split it without losing the 22-? I suppose after the split I could add the 22- back to the beginning of each element.
I haven't coded it yet
With split, you specify the separator. 22- is not a separator, but part of the record.
You can still use split by separating on the zero-width space that's followed by 22-.
split /(?=22-)/

How to name perl module, SomeModule vs Some::Module [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Is there any preferred naming convention for perl modules?
For example, what is more common practice in perl world - SomeModule or Some::Module? Maybe there are some cases when one style is better than another?
If you take a look at CPAN you will see that, by and large, module names are organised into top-level categories for the first segment of the name, and a distinctive name within that category for each module. For instance, the top ten categories (by distribution count) are
Net
App
WWW
Test
Data
Catalyst
Acme
Text
Dist
HTML
The second part of the name is usually either to identify it within all other modules of that category (such as HTML::TreeBuilder), or as a subdivision of a large category (like Net::FTP::* modules)
There may be a third section to the name, which represents either a component module of an overall set (for example DBIx::Class::Relationship and DBIx::Class::ResultSet ) or a separate module that has been subclassed from another (like HTML::TreeBuilder::XPath)
For too long there has been no control over the names of the modules uploaded to CPAN, and some parts of it can be a bit of a mess. However it does represent a defined and growing set of names that you should try to avoid with your own package identifiers. Your example isn't very realistic, but I would probably go with just SomeModule, as just inserting a pair of colons between every pair of words is definitely not the way to go
If you have multiple modules you can start gathering them together into categories, and it would help if you used a top-level category (like Site or Company) that avoided clashes with any CPAN modules that you could use. Examples could be Site::Utils::Matrices and Site::Utils::StringProcessing
The one major rule is that your package names should be in CamelCase, as all lower-case names are reserved for Perl pragmas
Since stevieb's solution has been deleted, it's worth me reposting a link to brian d foy's excellent On The Naming of Modules which makes many salient points
It depends whether or not you intend to put your module on CPAN. If you are putting it on CPAN, you should be reading perldoc perlmodstyle anyway. If however you are just using the modules privately, the most relevant point is that the :: is used to signify a directory hierarchy. Ex:
use lib 'my_module';
use Some::Module;
This loads a module named "Module.pm" in a folder called "Some", in the directory "my_module".
This is not to be confused with package names, which often also use ::. With package names, :: is usually used to designate conceptual hierarchies or relationships between packages, such as classes and sub-classes.

Form fields validation: which characters to include / exclude? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
A google search gave me the methods to validate form fields, but I can already construct them. My question is, which are the characters that are safe to include and which are to exclude in a form field? Specifically, username and password.
A brief explanation would be nice too.
Thanks.
You need to exclude all characters you will never have inside you datas.
Do you think it would be any sense to have special characters if your usernames/passwords must only contains alphanumeric characters ?
Look at some REGEX for JAVA or for PHP.
There is a regexp reference table which could be usefull too.
If you give us more information about the langage you are using, we could maybe help us more.
Have a good day!
[UPDATE]
There is the security reference which is very good and the OWASP website which is a real reference for any web security related topics, look at the OWASP Cheat Sheets.
#**Cross-Site Scripting Vulnerabilities?**
#for any programming language, the chars you should reject or handle properly are:
> < ( ) [ ] ' " ; : / |
#for PHP, tools to handle with care:
strip_tags(), utf8_decode(), htmlspecialchars(), strtr()
#do Positive/Negative filtering
#check Encoding
#**SQL Injection ?**
#etc...
[/UPDATE]
If you properly sanitize your input and output, there's nothing you need to be afraid of.
Note: I'm assuming you're using PHP as your server side language.
First, use PDO (or MySQLi) with prepared statements, to eliminate the risk of SQL Injection.
Second, anything that will be displayed on your site should be sanitized against XSS attacks (so that users don't register a username of <script>doSomeEvilStuff()</script>).
That's it basically, if you're really paranoid, you should be using a whitelist (to only allow certain characters) and not a blacklist (to only disallow certain characters), since someone will always find a way to bypass a blacklist, but no one can bypass a whitelist.
For usernames, I don't see the need for anything more than /[a-zA-Z0-9_.\s!$%^&*\-+=]/ You may think otherwise. In any case, don't allow /[`<>(){}[]]/

Search for keyword and then conditional on finding it search for another keyword from a list of words using Perl [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
My question concerning Perl is very similar to the one involving Python answered here:
How can I search within a document for a keyword and then subsequent key words within a set number of lines of the original keyword in Python?
This involves searching for one keyword and then for another from a list of keywords (say you have a list of 4 words) in the vicinity of the original keyword (say plus minus 5 lines) and then when matched printing out a range of lines (say plus minus 20 lines from the original keyword)
Two extensions if possible:
Ext 1: in the printout highlight key words
Ext 2: search all files from a directory and add the filename to the printout (filename in one line, followed by the lines extracted from the file)
I would appreciate even if directed to similar examples...
Read in the File as a nice array:
my #line = <FILE>;
Search for the 1st word:
my $i;
foreach $i (0 .. $#line) {
last if $line[$i] =~ /$firstWord/i;
}
Get the surrounding using an array slice:
my #surrounding = #line[$i-5 .. $i+5];
One should however use some index checking like
[0<=$i-5 ? 0 : $i-5 .. $i+5<#line ? $i+5 : $#line]
repeat
Profit
The rest is left as an exercise to the reader.
For highlighting write
$line[$i] =~ s{($firstWord)}{<strong>$1</strong>};
or similar, depending on your output medium. map is your friend for this.

Plural form of word "mutex" [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
What is the correct plural form of the portmanteau mutex. Is it mutexes or mutices?
From a purely linguistics point of view, the correct usage is mutexes because the word mutex is not Latin in origin. Prescriptivists would wail in anguish if mutices were to enter regular usage.
The -ices usage (e.g., the plurals of index and vertex) is falling out of favor. Indexes and vertexes are both correct usage, for example.
Let their common usage decide...
GoogleFight
Everyone knows that the correct answer is Mutii.
Mutexes. It's correct in a de facto manner--- the vast majority of people (in my experience, certainly) call them mutexes, not mutices, and English is a language that's defined by use. :)
As mutex is short for "mutual exclusion", I would only imagine that "mutual exclusions" would become mutexes. Mutices would be confusing. Better to be unambiguous.
As a side note: it's not a portmanteau, or it would be a mutsion.
There's no official correct form because 'mutex' hasn't gained wide enough circulation to enter any of the major English dictionaries. Thus, the most correct term is whatever is used most by people. And I think that Google hits are a pretty good indicator of (relative) usage frequency, as great_lama has pointed out.
Other English nouns that end in -ex or -ix:
Affix
Annex
Apex
Appendix
Cervix
Circumflex
Complex
Cortex
Crucifix
Duplex
Helix
Ibex
Index
Infix
Latex
Matrix
Phoenix
Prefix
Postfix
Reflex
Remix
Suffix
Vertex
Vortex
And lots more less common words. If you look up these in the dictionary, you'll find that most of them have both plurals shown as acceptable. Several have only the -exes/-ixes form, but few or none (depending on the dictionary you use) have only the -ices form.
In conclusion, I believe mutexes to be the correct plural form of mutex.
Either/or. I've seen both (though mutexes is considerably more common).
Mutex is not in any real dictionary I know of, so there's no "official answer."
Index can be pluralized to indexes or indices, though, so it makes sense that mutex could follow suit.
Since the word apex can be pluralized as either apexes or apices, I'd say you can pronounce it either mutexes or mutices. Whatever suits you.
I think that the hysterical raisins (in this case the fact that "mutex" is a portmanteau) should not be given too much weight in resolving such issues.
Perhaps it would be more useful to consider similar words and their usage; reflex -> reflexes for example.
Or, use the simplest choice: most pluralizations in english use -s/-es (depending on whether last letter is a perceived vowel); in this case -es.
I guess I can't see any reason to use the alternative, except as some sort of tribute to Latin, once thought to be the noblest of all languages. :)
Maybe it is like sheep? Singular and plural?