logic

Web crawler links/page logic in PHP

泄露秘密 提交于 2019-12-11 05:47:28
问题 I'm writing a basic crawler that simply caches pages with PHP. All it does is use get_file_contents to get contents of a webpage and regex to get all the links out <a href="URL">DESCRIPTION</a> - at the moment it returns: Array { [url] => URL [desc] => DESCRIPTION } The problem I'm having is figuring out the logic behind determining whether the page link is local or sussing out whether it may be in a completely different local directory. It could be any number of combinations: i.e. href="..

Logical question: Given corners, find Center of Quadrilateral?

ε祈祈猫儿з 提交于 2019-12-11 05:01:00
问题 Given the cordinates of all corners of a quadrilateral, how can the cordinates of its center be found? Thanks. 回答1: Origin = x=0,y=0 a(0,0) b(10,0) c(0,5) d(10,5) a+(b-a/2)=5 a+(c-a/2)=2.5 centre co-ordinate = 5,2.5 or dx-ax/2=5 dy-ay/2=2.5 with those formulas it wouldn't matter if the sides were uneven the centre can always be calculated. Regards Ray 回答2: I suppose you are talking about the centroid or center of masses. In a quadrilateral there are two general ways of getting the coordinates

Abs() - issue with absolute value function in PHP

為{幸葍}努か 提交于 2019-12-11 03:49:21
问题 Can anyone explain why this code does this in regards to abs() (absolute value) - In my code it will display 'GREATER' - although 0.50 is never GREATER than 0.5, am I missing out something here with the abs function? $logic = abs(1.83333333333 - 2.33333333333); // 0.50 $limit = 0.50; if ($logic > $limit) { echo 'IS GREATER'; } else { echo 'IS NOT GREATER'; } 回答1: Passing floating point numbers to abs you will get a floating point number as result. In that case you can experience problems with

How to multiply an int with a fraction

青春壹個敷衍的年華 提交于 2019-12-11 03:39:31
问题 I need to multiply an int by a fraction using bitwise operators without loops and such. For example, I need to multiply by x by 3/8. I thought you would: int value = (x << 1) + x; // Multiply by 3 value = (value >> 3); // Divide by 8 But that doesnt work. I tried googling binary times fraction but that give floating point examples. I dont know exactly if this homework is for floating point but my hunch is no but getting me prepared for it. So any suggestions? I need to round toward zero so

Struts logic tag equals not working

ぐ巨炮叔叔 提交于 2019-12-11 03:35:49
问题 Very quick questions. Could someone explain to me why this code does not work? <%@ taglib prefix="logic" uri="/WEB-INF/struts-logic.tld" %> <% int myValue= 2; %> myValue: <%=myValue%> <br/> <logic:equal name="myValue" value="2" scope="session"> logic:equal works! </logic:equal> Even if I change myValue to a String is still doesn't work Quite frustrating, cause I know it's going to be something obvious. Thanks in advance KS Working example! <%@ taglib prefix="logic" uri="/WEB-INF/struts-logic

Equality for constants in Z3 SMT solver

雨燕双飞 提交于 2019-12-11 03:21:25
问题 I am using the Z3 SMT solver by Microsoft, and I am trying to define constants of a custom sort. It seems like such constants are not unequal by default. Suppose you have the following program: (declare-sort S 0) (declare-const x S) (declare-const y S) (assert (= x y)) (check-sat) This will give "sat", because it is of course perfectly possible that two constants of the same sort are equal. Since I am making model in which constants have to be different from each other, this means that I

Merge multiple rows (having some non string values) with same ID into one delimited row in pandas

最后都变了- 提交于 2019-12-11 03:17:00
问题 I have a dataset like this: ID Name 1 a 1 b 1 2 1 3 2 er 2 get 2 better 3 123 3 cold 3 warm 3 sweet 3 heat and I want to group together this data such that data column "name" having same "id" is merged together using a delimiter. Something like this: ID Name 1 a,b,2,3 2 er,get,better 3 123,cold,warm,sweet,heat and so on. Can anyone provide me a pythonic way of doing this? 回答1: Use ','.join in a groupby df.groupby('ID').Name.apply(','.join) ID 1 a,b,c,d 2 er,get,better 3 hot,cold,warm,sweet

Barack doesn’t like anything that Donald likes

心已入冬 提交于 2019-12-11 02:14:15
问题 How to express: Barack doesn’t like anything that Donald likes. in Protege? My attempt: I have Barack and Donald as individuals and like as a property , however, when clicking on Barack , the best I can get is: Barack like Donald which is not good. Any ideas? The answer appears to not be working. 回答1: In the individuals tab, where you can assert the type (not object property assertion) of an individual, you write (for Barack): likes only (not (inverse likes value Donald)) or likes only (not

Finding matching phrases between two pieces of text?

冷暖自知 提交于 2019-12-11 01:58:36
问题 My objective is to find similar phrases from two pieces of text. I know that common words will be a problem. For example, and the we are the . In that case, I think a filter will be necessary. I want to know if this was a good approach? This uses recursion, if it finds a match, it sees if the next word is also a match, and continues on till there s no match. 1. the cat is on the roof 2. a man is on the stage A1 = [the, cat, is, on, the, roof] A2 = [a, man, is, on, the, stage] [the]: no match

Logic programming help

大兔子大兔子 提交于 2019-12-11 01:28:03
问题 A = if infos !empty and inputs empty - do remove; B = if infos empty and inputs !empty - do add; C = if infos !empty and inputs !equal to infos - do add; We can have like: if B //it's the most common operation, so at the beginning. { //add } else { //remove } elseif(c) { //the same add } I believe this can be better thinking. Can I have your help? Thanks in advance, 回答1: if (infos != inputs) { if (empty(inputs)) { // remove } else { // add } } Remember, the outermost condition checks that