Algorithm 1: Match social media posting with sosa:observable property |
procedure GETSOSAOBSERVABLEPROPERTY(socialMediaTokens) smTokens ←nlp(socialMediaTokens) sosaObservableProperties ←temperature,humidity,wind,gust,pressure observablePropertiesTokens ← nlp(sosaObservableProperties) tokenSimilarity ← [] dictTokenSimilarity ← [] for eachToken in observablePropertiesTokens do for eachsmToken in smTokens do if eachToken.text != eachsmToken.text and eachtoken.similarity(eachsmToken) > 0.50 then tokenSimilarity.append(eachToken.similarity(eachsmToken)) dictTokenSimilarity[eachToken.text]=eachToken.similarity(eachsmToken) end end if max(dictTokenSimilarity.items(), key ←lambda x : x[1]) is None then NSOP , 0 ; /* NSOP ← NoSimilarObservableProperty ∗ / tokenSimilarity.append(eachToken.similarity(eachsmToken)); dictTokenSimilarity[eachToken.text]=eachToken.similarity(eachsmToken) else mostSimilarObservableProperty,mostSimilarObservablePropertyValue =max(dictTokenSimilarity.items(),key ←lambda x:x[1]) ; /* return the most similar observable property(token) with max similarity of all tokens */ return mostSimilarObservableProperty, mostSimilarObservablePropertyValue end end end procedure |