is it possible to extract "Description" of an ecoinvent activity? - brightway

I'm trying to automate the extraction of the "Description" of activities from ecoinvent database (e.g., "wood preservation facility construction, dipping/immersion tank | wood preservation facility, dipping/immersion tank"), using brightway2.
As there seems no such an attribute called "description" in the activity object, I tried "comment" instead. I was expecting the following content from the activity named "wood preservation facility construction, dipping/immersion tank | wood preservation facility, dipping/immersion tank":
"The dipping or immersion tank consists of the main steel tank containing the preservative and an second, larger steel tank as the retention tank, within which the first tank is located. As an alternative design the main tank can be placed in a sealed concrete construction, serving as the retention tank. Appart from the tanks, a lifting device (for lifting the wood into and out of the tank) as well as a hold-down device (to ensure complete immersion) are inventoried.;The length of the inventoried tank is 12 m, corresponding to a medium sized tank, The batch size is between 12 - 16 m3 of wood. Assuming an average input of 9 l of preservative/m3 , a yearly throughput of 6000 m3 of wood and a service life of 75 years, about 4.05E06 kg of wood preservative are applied over the service life of the tank.;;Data on land use and on the building hall are taken from pressure vessel processes as no specific data on these infrastructure inputs could be gathered. These values refer to a yearly throughput of 6000 m3 of wood.; Infrastructure dataset containing the main elements of the facility. The land area and the material (production and disposal) needed for a preservative treatment plant for dipping or immersion treatment including strorage area is included. 60 - 90 kg of 2-component laquers are not inventoried." The content is presented in the "Description" field under "General Information" section, if you open the activity in OpenLCA software.
But what was returned was the following:
"Data from Germany and Switzerland. Location of plant within Europe of minor importance" (which is the content of another "Description" field under "Geography" section, if you open the activity in OpenLCA software).
Is there any way I can retrive the correct Description content of an activity using bw2? Thanks

Related

Splitting txt file into multiple based on custom delimiter

I have a txt file with around 100 multiple-choice questions. I want to split them into 100 txt files containing one question. The delimiter will be "number.", example - 1. for the first question, 2. for next like this. the issue is a "number." can emerge amidst a question also, so that can be checked by ensuring that "(d)" was encountered prior to that "number.".
Sample text -
1.Consider the following statements with regard to the State Council of Ministers:1. The constitution specifies the size of the state council of ministers and the ranking of ministers.2.The advice tendered by the ministers to the Governor shall not be inquired into in any court. Which of the statements given above is/ are correct? (a)1 only(b)2 only(c)Both 1 and 2(d)Neither 1 nor 22.Consider the following statements with reference to Public Accounts Committee:1. The committee was set up under the provisions of the Government of India Act1919.2.Speaker is the ex- Officio Chairman of the committee. A minister cannot be a member of the committee. Which of the statements given above is/are not correct? (a)1 only(b)2 and 3 only(c)1 and 2 only(d)2 only
The text is like mentioned above, and it should be split like this -
1.Consider the following statements with regard to the State Council of Ministers:1. The constitution specifies the size of the state council of ministers and the ranking of ministers.2.The advice tendered by the ministers to the Governor shall not be inquired into in any court. Which of the statements given above is/ are correct? (a)1 only(b)2 only(c)Both 1 and 2(d)Neither 1 nor 2
2.Consider the following statements with reference to Public Accounts Committee:1. The committee was set up under the provisions of the Government of India Act1919.2.Speaker is the ex- Officio Chairman of the committee. A minister cannot be a member of the committee. Which of the statements given above is/are not correct? (a)1 only(b)2 and 3 only(c)1 and 2 only(d)2 only

How to extract a particular element/text inside an HTML using Python 3.x

This is my code:
import requests
from bs4 import BeautifulSoup
r=requests.get('https://www.morningstar.com/stocks/xtse/enb/quote')
c=r.content
soup=BeautifulSoup(c,"html.parser")
print(soup.prettify())
for item in soup.find("byId: {}".text):
print(item.text)
Once I ran that, on the bottom most of the whole html file it shows:
window.__NUXT__=(function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N){J.id=1014028;J.title="Enbridge Expects a Rebound in 2021, Increases Dividend by 3%";J.deck=y;J.locale=K;J.publishedDate=L;J.updatedDate=L;J.paywalled=b;J.authors=[{holdings:[o,p,q,r,s,t,k,u,n,m,l,j,i],id:h,name:c,jobTitle:g,byLine:f,shortBio:e,image:d,isPrimary:b}];J.authorDisclosure=[];J.body=[{type:w,contentObject:[{type:x,content:"Wide-moat Enbridge announced 2021 full-year adjusted EBITDA guidance of CAD 13.9 billion-CAD 14.3 billion at its annual investor day on Dec. 8, which is above our previous forecasts. The midpoint of the guidance also implies a 6% increase from 2020 expected EBITDA. Enbridge believes that the increased performance will be driven by a recovery of Mainline volumes and the associated downstream pipelines; customer growth in the gas utilities business; rate increases on its gas pipelines; and the impact of new projects, including the Line 3 replacement. At this point, the Mainline’s heavy oil capacity is full, and demand for light capacity continues to increase. Accordingly, Enbridge expects first-quarter 2021 volumes to average 2.7 million barrels of oil per day, which is also above our previous expectations and compares favorably with 2.56 mmbbl\u002Fd in third-quarter 2020.",gated:a}],gated:a}];M.name=H;M.performanceId=A;M.secId=A;M.ticker=N;M.exchange=I;M.type=F;return {layout:"default",data:[{marketPrice:{value:43.55,filtered:a,date:{value:v,filtered:a}},premiumDiscount:{value:"-92.6",filtered:b,date:{value:v,filtered:a},text:{value:"Discount",filtered:a},type:{value:D,filtered:a}},threeStarRatingPrice:{value:"86.9",filtered:b},headquarterAddress1:{value:"425-1st Street SW",filtered:a},headquarterAddress2:{value:"Suite 200, Fifth Avenue Place",filtered:a},industry:{value:"Oil & Gas Midstream",filtered:a},stockStarRating:{value:"6",filtered:b,date:{value:v,filtered:a},text:{value:"Undervalued",filtered:a},type:{value:D,filtered:a}},fiscalYearEndDate:{value:"2020-12-31",filtered:a},headquarterState:{value:"AB",filtered:a},reportDate:{value:"2020-09-30",filtered:a},headquarterPostalCode:{value:"T2P 3L8",filtered:a},stewardshipRating:{value:"Bkwvsknl",filtered:b,date:{value:v,filtered:a}},companyProfile:{value:"Enbridge is an energy generation, distribution, and transportation company in the U.S. and Canada. Its pipeline network consists of the Canadian Mainline system, regional oil sands pipelines, and natural gas pipelines. The company also owns and operates a regulated natural gas utility and Canada’s largest natural gas distribution company. Additionally, Enbridge generates renewable and alternative energy with 2,000 megawatts of capacity.",filtered:a},fairValue:{value:"23.3",filtered:b,date:{value:"2020-12-08",filtered:a},type:{value:D,filtered:a}},fax:{value:"+1 403 231-5929",filtered:a},fiveStarRatingPrice:{value:"58.3",filtered:b},sector:{value:"Energy",filtered:a},economicMoat:{value:"Nsfq",filtered:b,date:{value:v,filtered:a}},ticker:N,website:{value:"https:\u002F\u002Fwww.enbridge.com",filtered:a},headquarterCountry:{value:"Canada",filtered:a},contactEmail:{value:"investor.relations#enbridge.com",filtered:a},fourStarRatingPrice:{value:"77.0",filtered:b},economicMoatTrend:{value:"Zcbqwh",filtered:b,date:{value:v,filtered:a}},headquarterCity:{value:"Calgary",filtered:a},phone:{value:"+1 403 231-3900",filtered:a},universe:{value:"EQ",filtered:a},exchange:I,totalEmployees:{value:11300,filtered:a},twoStarRatingPrice:{value:"54.91",filtered:b},fairValueUncertainty:{value:"Nnczrm",filtered:b},name:H,performanceId:A,secId:A,type:F,articles:[{title:"Epic Oil Crash Sets Up Brutal Downturn for Energy Sector",link:"\u002Farticles\u002F980350\u002Fepic-oil-crash-sets-up-brutal-downturn-for-energy-sector",caption:"But recovery is inevitable, and stocks look very cheap--just watch out for bankruptcy risk.",author:"Preston Caldwell",label:C,isVideo:a},{title:"Enbridge's Sell-Off Looks Exaggerated",link:"\u002Farticles\u002F978902\u002Fenbridges-sell-off-looks-exaggerated",caption:"The market is underestimating long-term cash flows once oil prices normalize.",author:c,label:z,isVideo:a},{title:"Executive Orders More Symbolic Than Material for Pipelines",link:"\u002Farticles\u002F923945\u002Fexecutive-orders-more-symbolic-than-material-for-pipelines",caption:"We're not changing our outlook for our midstream coverage.",author:"Stephen Ellis",label:C,isVideo:a},{title:"New Permit Moves Keystone XL Forward",link:"\u002Farticles\u002F922171\u002Fnew-permit-moves-keystone-xl-forward",caption:"Our fair value estimates for TransCanada and Enbridge are unchanged.",author:c,label:z,isVideo:a},{title:"Enbridge Hikes Dividend, Remains Deeply Undervalued",link:"\u002Farticles\u002F904922\u002Fenbridge-hikes-dividend-remains-deeply-undervalued",caption:"It has a wide moat and an attractive yield, and now's the time to invest.",author:c,label:z,isVideo:a},{title:"Concerns About Enbridge's Dividend Are Overblown",link:"\u002Farticles\u002F870105\u002Fconcerns-about-enbridges-dividend-are-overblown",caption:"The wide-moat company is on course to boost its dividend and offers hefty upside.",author:c,label:z,isVideo:a},{title:"Enbridge's Growth Portfolio Is Underappreciated",link:"\u002Farticles\u002F841990\u002Fenbridges-growth-portfolio-is-underappreciated",caption:"And the company continues to reward investors with annual dividend growth.",author:c,label:z,isVideo:a},{title:"Enbridge's Economic Moat Widens",link:"\u002Farticles\u002F565094\u002Fenbridges-economic-moat-widens",caption:"Shifting economics and supply dynamics provide growth opportunities.",author:"David McColl",label:C,isVideo:a}],analysis:{id:1014019,title:"Enbridge Increases Its Dividend by 3%",locale:K,publishedDate:B,updatedDate:B,paywalled:b,authors:[{holdings:[o,p,q,r,s,t,k,u,n,m,l,j,i],id:h,name:c,jobTitle:g,byLine:f,shortBio:e,image:d,isPrimary:b}],authorDisclosure:[],body:[],pillars:{investmentThesis:{title:"Business Strategy and Outlook",publishedDate:E,authors:[{holdings:[o,p,q,r,s,t,k,u,n,m,l,j,i],id:h,name:c,jobTitle:g,byLine:f,shortBio:e,image:d,isPrimary:b}],body:[{type:w,contentObject:[{type:x,content:"Enbridge is an energy distribution and transportation company in the United States and Canada. It operates crude and natural gas pipelines, including the Canadian Mainline system. It also owns and operates Canada's largest natural gas distribution company.",gated:a}],gated:a}]},moat:{title:"Economic Moat",publishedDate:E,authors:[{holdings:[o,p,q,r,s,t,k,u,n,m,l,j,i],id:h,name:c,jobTitle:g,byLine:f,shortBio:e,image:d,isPrimary:b}],body:[{type:w,contentObject:[{type:x,content:"Midstream companies process, transport, and store natural gas, natural gas liquids, crude oil, and refined products. There are multiple ways for midstream companies to build moats, but efficient scale is the dominant source. Hydrocarbons are produced and consumed in different places and in different forms from how they come out of the ground. Midstream firms transport and process hydrocarbons. Once a transport route is established, there's usually little need to build a competing route. Doing so would drive returns for both routes below the cost of capital. Thus, pipelines are generally moaty because they efficiently serve markets of limited size.",gated:a}],gated:a}]},managementAndStewardship:{title:"Stewardship",publishedDate:B,authors:[{holdings:[o,p,q,r,s,t,k,u,n,m,l,j,i],id:h,name:c,jobTitle:g,byLine:f,shortBio:e,image:d,isPrimary:b}],body:[{type:w,contentObject:[{type:x,content:"President and CEO Al Monaco has been with Enbridge since 1995, serving in his current role since 2012. During his tenure at Enbridge, Monaco has experience in all business segments, international business development, corporate planning, and finance. His experience in various business segments, corporate development, growth projects, and finance positions him to successfully lead the proposed pipeline and gas distribution growth projects.",gated:a}],gated:a}]},enterpriseRisk:{title:"Risk and Uncertainty",publishedDate:E,authors:[{holdings:[o,p,q,r,s,t,k,u,n,m,l,j,i],id:h,name:c,jobTitle:g,byLine:f,shortBio:e,image:d,isPrimary:b}],body:[{type:w,contentObject:[{type:x,content:"Enbridge’s profitability is not directly tied to commodity prices, as pipeline transportation costs are not tied to the price of natural gas and crude oil. However, the cyclical supply and demand nature of commodities and related pricing can have an indirect impact on the business as shippers may choose to accelerate or delay certain projects. This can affect the timing for the demand of transportation services and\u002For new gas pipeline infrastructure.",gated:a}],gated:a}]},valuation:{title:"Fair Value and Profit Drivers",publishedDate:B,authors:[{holdings:[o,p,q,r,s,t,k,u,n,m,l,j,i],id:h,name:c,jobTitle:g,byLine:f,shortBio:e,image:d,isPrimary:b}],body:[{type:w,contentObject:[{type:x,content:"Our fair value estimate of $43 (CAD 57) per share is based on a discounted cash flow model. We believe that Enbridge’s broad network of midstream assets and geographic diversification will serve it well in the low oil and gas price environment, and crude and natural gas pipeline expansions in growing regions will fuel EBITDA growth. Our cash flow forecasts incorporate the addition of the Line 3 replacement pipeline, but we adjusted our Canadian fair value downward to a reflect a risk-weighted probability of 80% that the pipeline is built.",gated:a}],gated:a}]},notes:J},notes:J},listedCurrency:{value:"CAD",filtered:a}},{}],error:y,state:{history:{currentRoute:"\u002Fstocks\u002Fxtse\u002Fenb\u002Fquote",previousRoute:y,returnRoute:y},ids:{byTicker:{"ST::XTSE::ENB":M},byId:{"0P0000681O":M}},markets:{movers:{gainers:[],losers:[],actives:[]},quotes:{},trailingReturns:{},intradayTimeSeries:{},lastRefreshed:y},player:{nowPlaying:y},siteAlert:{message:G,type:G},user:{userType:"visitor",isAdvisor:a,contentType:"e7FDDltrTy+tA2HnLovvGL0LFMwT+KkEptGju5wXVTU="}},serverRendered:b,serverDate:new Date(1607916811524)}}(false,true,"Joe Gemino","https:\u002F\u002Fim.mstar.com\u002FContent\u002FCMSImages\u002F78x78\u002F2008-jgemino-78x78.jpg","Joe Gemino, CPA, is a senior equity analyst for Morningstar.","Joe Gemino, CPA","Senior Equity Analyst","2008","MST50","SGDLX","FB","TRRNX","DODIX","DODGX","MORN","MOAT","AAPL","V","T","DIS","DODBX","2020-12-11","p","text",null,"Stock Strategist","0P0000681O","2020-12-08T18:13:00Z","Stock Strategist Industry Reports","Qual","2020-04-16T14:59:00Z","ST","","Enbridge Inc","XTSE",{},"en-US","2020-12-08T18:28:00Z",{},"ENB"));
My question: how do I extract the information inside "byID:" so that print(item.text) will give me "0P0000681O" only.
If you only need to get a value, use a string find.
from simplified_scrapy import utils, SimplifiedDoc, req
html = req.get(
'https://www.morningstar.com/stocks/xtse/enb/quote')
start = html.find('byId:{"')
html = html[start+len('byId:{"'):]
end = html.find('":')
print(html[:end])
Result:
0P0000681O

Identifying class diagram classes from a use case specification?

I'm currently trying to learn the construction of class diagrams for an upcoming exam, although I'm having difficulties knowing how to identify classes based on a use case specification (or any similar description of a system).
I understand people here can be reluctant to help with education based questions, I just wanted to clarify that I'm not asking for the work to be done for me, I just need to be pointed in the right direction.
I'm going over a past revision paper which contains a use case specification for the process of 'purchasing an ice cream' at a vending machine. The first question is to identify 9 typical classes from this specification.
I understand a class is like an object and usually identified by a noun, although my confusion is how I am able to extract 9 classes as I can only seem to find 6, that is if they're even correct:
Customer, Student, Staff, Touch Screen, Change Dispenser, and Member Card.
Here is the use case specification, apologies for the length:
Ben & Jerry’s company has just installed a new vending machine at a
University; it has a variety of ice creams available, in the format of
tubs or mini-tubs of different flavours. Products are subsidised for
students and staff but not for the rest of users; such that a customer
can insert a member card in a card reader and the subsidised prize for
the selected ice cream is displayed. You have designed a use case
model of the system, and identified a single use case (“purchase an
ice cream”) where the main actors are the customers.
ID: VM1
Name: Purchase a tub
Main Actors:
Subsidised customer (staff and students) 2 Non-subsidised customer
Pre-conditions:
Machine is on and works perfectly fine
There is stock of drinks and coins
There is sufficient stock of coins in the machine for providing change
There is sufficient stock of products
Main Flow:
Machine displays a welcome message
Student/staff inserts member card
System validates member card
Customer selects the tub by pressing the touch screen
Machine displays the subsidised price for the selected ice cream
REPEAT until sufficient coins entered: 6.1 Customer enters coin 6.2 Touch screen displays the amount entered so far
System dispenses the tub
IF too many coins are entered change is delivered
Price is added to the weekly total amount
Machine resets
Post Condition: Ice cream purchased
Alternative flow 1:
IF customer does not have sufficient coins 6.1 Customer presses the return button 6.2 System returns the entered coins
Alternative flow 2:
IF validation is unsuccessful 3.1 Message informing user 3.2 Non-subsidised price is show 3.3 Use case continues main flow 4
If anybody can help I'd really appreciate it. Thanks
You have mostly identified a number of actors, few classes itself. To start your design, ask yourself what the system under consideration (SUC) is. Obviously a vending machine. Now look at the UC how this SUC acts. There are a couple of hints:
control resources (temperature, ice cream, tubs, etc.),
control collection of money,
control dispension of ice cream.
For these you can create controller classes which look to the outside and act accordingly (read temp -> turn on cooling; count money -> start vending; etc.)
The vending process with customer interaction is probably even more complex (show offers, make selection, pricing, etc.)
As you already guessed, this is no tutorial point. However, those are the basic steps to start the design. You can go on and create sequence diagrams to verify collaboration between the single classes (lots of exceptions like: temp controller starting to yell when temp does go up too much).

Determining customary distance unit from ISO 3166 country code

ISO 3166 defines country codes such as GB, US, FR or RU.
I would like a reasonably definitive association from these country codes to the customary unit of measure for distances between places in those countries.
Specifically on iOS and OS X, the country code can be retrieved from NSLocale:
[[NSLocale currentLocale] objectForKey: NSLocaleCountryCode];
NSLocale also provides a way to see if a country uses metric or non metric units:
const bool useMetric = [[[NSLocale currentLocale] objectForKey: NSLocaleUsesMetricSystem] boolValue];
However, this is not sufficient. For example, in Great Britain (GB) the metric system is widely used, but distances between places continue to be officially measured in miles rather than kilometres.
I also faced this problem :-)
Countries which uses Metric system but still use miles :--
1. GB is only exception which still uses miles instead of metric.
Note: Canada also stared using KMs for road transport. Although, Canada still follows miles for train and horse transport
Countries which do not uses Metric System
Liberia, Myanmar and United States of America.
Note: Myanmar (Formerly Burma) is planning to move to metric system. Currently, Myanmar uses its own system different from imperial and metric.
In my app, i check whether country uses imperial or metric.
if (metric) then assign kms for all countries except britan
if (imperial) then assign miles for all countries except Burma
if burma then assign burma unit
if britan then assign miles
A chart showing countries using miles per hour for road speeds is available. It cites Wikipedia's articles on miles per hour as its source, which has the following to say:
These include roads in the United Kingdom,[1] the United States,[2] and UK and US territories; American Samoa,[3] the Bahamas,[4] Belize,[5] British Virgin Islands,[6] the Cayman Islands,[7] Dominica,[8] the Falkland Islands,[9] Grenada,[10] Guam,[11] Burma,[12] The N. Mariana Islands,[13] Samoa,[14] St. Lucia,[15] St. Vincent & The Grenadines,[16] St. Helena,[17] St. Kitts & Nevis,[18] Turks & Caicos Islands,[19] the U.S. Virgin Islands,[20][21] Antigua & Barbuda (although km are used for distance),[22] and Puerto Rico (same as former).[22]
I don't see a way to download this as data keyed from ISO3166 country code, but it's not a huge task to compile one.
I'll leave this answer unaccepted in case a better suggestion is available.
Officially, road distances in the UK are in kilometres, but road signs are in miles. Confusing? Yes! When a road engineer get aplan of a road, everythign is in kiolometres, government statistics are in kilometres, but road signs and car odometers are in miles. See https://en.wikipedia.org/wiki/Driver_location_sign for more info.

Supply Demand Modeling

I thought I would ask the SO community on helping me with a project that I am currently working on. I need to model the price for a widget in a market situation. The price for the widget should be a result from the current supply and demand. Users will be able to buy and sell the widget at the fixed price. As users buy the widget the demand will go up along with the price. Conversely as users sell the widget the supply will go up and the price will go down. The quantity and current price of the widget will be stored in a database along with the total number of buys and sells for the widget.
Protrade.com has an excellent example of buying and trading widgets (players and teams), I would want to model my system in a similar fashion.
Is there any good programming libraries that will accurately model a market based on supply and demand?
Unfortunately I do not know of any libraries, but perhaps you can tap into Excel's statistics functions.
My opinion follows.
This is why economics is so boring, everything is supply/demand.
Something along the lines of the following should work as a start:
ListPrice = (Cost + Profit) * (demand/supply * economic-factor)
where economic-factor is some determined constant.
If you have some historical data, eg daily supply/demand ratio's you could factor it in, perhaps using some time-based scale.

Resources