Qualified cardinality restriction definition in Protege - ontology

I was following this tutorial -> LINK
At page 75, it explains how to define a FourCheesePizza using a qualified cardinality restriction. Under the instructions it says "With this description a FourCheesePizza can still also have other relationships to other kinds of toppings. In order for us to say that we just want it to have four cheese toppings and no other toppings we must add the keyword 'only' (the universal quantifier)".
Now, my definition of FourCheesePizza is:
Pizza and hasTopping exactly 4 CheeseTopping
but I don't understand where to add the 'only' keyword, because I only get syntax errors.

If you want a four cheese pizza with nothing else than cheese, you have to define it in this way:
Pizza and hasTopping exactly 4 CheeseTopping and hasTopping only CheeseTopping

Related

machine learning - check & parse sentence related to previous sentence

During natural language processing, what should be the logic to determine if the current sentence has "cues" which needs to be taken from the previous sentence while parsing.
I am not sure how to aptly describe this issue or what sub-topic of NLP it is referred as, so I would present an example.
If previous sentence was Find me an Italian restaurant in New York city
and the current sentence is What's the weather there tomorrow
How should the parser proceed to understand that there in the current sentence refers to New york which was mentioned in the previous sentence.
PS - I am fairly new to NLP, so please be kind here with your explanations.
An anaphor is an expression that refers back to a previous expression in a natural language discourse. For example: "Mary died. She was very old." The word she refers to Mary, and is described as an anaphoric reference to Mary. Mary is described as the antecedent of she. Anaphoric references are frequently pronouns, as in the example, but may also be definite noun phrases, as in: "Ronald Reagan frowned. The President was clearly worried by this issue." Here The President is an anaphoric reference to Ronald Reagan. Anaphors may in some cases not be explicitly mentioned in a previous sentence - as in "John got out his pencil. He found that the lead was broken." The lead here refers to a subpart of his pencil. Anaphors need not be in the immediately preceding sentence, they could be further back, or in the same sentence, as in "John got out his pencil, but found that the lead was broken." In all our examples so far the anaphor and the antecedent are noun phrases, but VP and sentence-anaphora is also possible, as in "I have today dismissed the prime minister. It was my duty in the circumstances." Here It is an anaphoric reference to the VP dismissed the prime minister.
For a fairly complete and quite entertaining treatment of anaphora, see Hirst, G. Anaphora in Natural Language Understanding: A Survey Springer Lecture Notes in Computer Science 119, Berlin: Springer, 1981.
You can also find an algorithm to solve the problem in this Paper.

Regexp for a name

I need to make sure people enter their first, middle and last names correctly for a form in Rails. So the first thought for a regular expression is:
\A[[:upper:]][[:alpha:]'-]+( [[:upper:]][[:alpha:]'-]*)*\z
That'll make sure every word in the name starts with an uppercase letter followed by a letter or hyphen or apostrophe.
My first question I guess doesn't have much to do with regular expressions, though I'm hoping there's a regular expression I can copy for this. Are letters, hyphens and apostrophes the only characters I should be checking in a name?
My second question is if it's important to make sure each name has at least 1 uppercase letter? So many people enter all lowercase names and I really want to avoid that, but is it sometimes legitimate?
Here's what I have so far that makes sure there's at least 1 uppercase letter somewhere in the name:
\A([[:alpha:]'-]+ )*[[:alpha:]'-]*[[:upper:]][[:alpha:]'-]*( [[:alpha:]'-]+)*\z
Isn't there a [:name:] bracket expression? :)
UPDATE: I added . and , to the characters allowed, surprised I didn't think of them originally. So many people must have to deal with this kind of regular expression! Nobody has any pre-made regular expressions for this sort of thing?
A good start would be to allow letters, marks, punctiation and whitespace. To allow for a given name like "María-Jose" and a last name like "van Rossum" (note the whitespace).
So that boils down to something like:
[\p{Letter}\p{Mark}\p{Punctuation}\p{Separator}]+
If you want to restrict that a bit you could have a look at classes like \p{Lowercase_Letter}, \p{Uppercase_Letter}, \p{Titlecase_Letter}, but there may be scripts that don't have casing. \p{Space_Separator} and \p{Dash_Punctuation} can narrow it down to names that I know. But names I don't...I don't know...
But before you start constructing your regex for "validating" a name. Please read this excellent piece on names by W3C. It will shake even your concepts of first, middle and last names.
For example:
In some cultures you are given a name (Björk, Osama) and an indication of who your father (or mother) was (Guðmundsdóttir, bin Mohammed). So the "first name" could be "Björk" but:
Björk wouldn’t normally expect to be called Ms. Guðmundsdóttir. Telephone directories in Iceland are sorted by given name.
But in other cultures, the first name is not given, but a family name. In "Zhāng Mànyù", "Zhāng" is the family name. And how to address her, would depend how well you know her, but again "Ms. Zhāng" would be strange.
The list of examples goes on and ends in a some 30+ links to Wikipedia for more examples.
The article does end with suggestions for field design and some pointers on what characters to allow:
Don't forget to allow people to use punctuation such as hyphens, apostrophes, etc. in names. Don't require names to be entered all in upper case – this can be difficult on a mobile device. Allow the user to enter a name with spaces , eg. to support prefixes and suffixes such as de in French, von in German, and Jnr/Jr in American names, and also because some people consider a space-separated sequence of characters to be a single name, eg. Rose Marie.
To answer your question about capital letters: in many areas of the world, names do not necessarily start with a capital letter. In Dutch for instance, you have surnames like "van der Vliet" where words like "van", "de", "den" and "der" are not capitalised. Additionally, you have special cases like "De fauw" and "Van pellicom" where an administrative error never got rectified, and the correct capitalisation is fairly illogical. Please do not make the mistake of rejecting such names.
I also know about town names in South Africa such as eThekwini, where the capital letter is not necessarily the first letter of the word. This could very well appear in surnames or given names as well.

ER diagrams: can two different notations be used in same diagram?

Within the one ER diagram is it possible to use the 1...* etc type of notation as well as the arrow notations in order to show cardinality constraints or does it have to be either or.
Often CASE tools such as CA ERwin or IBM Data Architect allow to display both relationship type (in IE crow-feet symbols) and also description of cardinality type.
If relationship is potentially one - to - many, it can described as broken crow feet symbol and cardinality type describtion of zero, one or M.

Forcing inconsitency by following qualified cardinality restriction

My question goes beyond one question which already has been asked here
I defined a qualified cardinality restriction like this one:
Pizza and hasTopping exactly 4 CheeseTopping and hasTopping only CheeseTopping
Now, how do I force inconsistency of the ontology when having an individual of asserted type 'FourCheesePizza' with less than four 'CheeseTopping' property assertions?
In other words: How do I state that the let us say two 'CheeseTopping' property assertions are definitely the only ones so that an inconsistency is forced?
Making a statement like that is not too difficult in OWL, but because of the open world assumption, it does mean that you have to make sure that a bit more knowledge is available. First, the two-cheese-pizza, let's call it p, that will be inconsistently labelled a four-cheese-pizza must somehow be declared to have exactly two cheese toppings. You can do this by giving p the type
hasTopping exactly 2 CheeseTopping .
This would be enough to get the inconsistency. If that seems a bit generic, and you want to specify the exact toppings that p can have, you could give p a type like
hasTopping only { Cheddar, Mozzarella }
which says that p can only have Cheddar and Mozzarella as toppings. At this point, we know that p can have at most two toppings (it could be just one, if Cheddar and Mozzarella haven't been declared to be different individuals), which is inconsistent with it being a FourCheesePizza and having four cheese toppings.

How- XLST Transformation

Just wanted to ask on how to get the author names in the given xml sample below and put an attribut of eq="yes". EQ means Equal Contributors.
This is the XML.
<ArticleFootnote Type="Misc">
<Para>John Doe and Jane Doe are equal contributors.</Para>
</ArticleFootnote>
This should be the output in other form of XML.
<AuthorGroups>
<Authors eq="yes">John Doe</Authors>
<Authors eq="yes">Jane Doe</Authors>
</AuthorGroups>
Assuming that JOhn Doe and Jane Doe are already defined in the list of authors but after the transformation, author tag should have the attribute eq="yes". Please help as I don't know much writing in xlst.
Thanks in advance.
There's not really enough information here to give you a clear answer.
If you have a list of authors, you could use fn:match() on each author's name in turn, maybe after changing space to \s+ in the pattern.
I normally use Perl to do this sort of thing, though, being careful not to disrupt the tagging structure.
In any case you'll either need to process the text a word at a time, probably recursively to find the longest match in cases where one name is just "John" and another is "John Doe". Watch that you don't add markup to names you've already processed.
In the case that the text really always says exactly what you have there, but with different names, though, you could have a template to match ArticleFootnote/Para[contains(., 'are equal contrubutors')] and either use substring() and substring-before() or the XSLT 2 pattern matching.

Resources