Lines that have three upper case characters in parenthesis like (LTI) - remember to escape certain characters - postgresql

This is a homework for postgresql regular expression that is to write a regular expression meeting the following requirement: Lines that have three upper case characters in parenthesis like (LTI) - remember to escape certain characters. I wrote the expression: purpose, ([A-Z]{3}). the answer is supposed to be 3 rows, but I got only 2 rows with my query. I don't why and solution. the purpose as followed:
we are dedicated to animal welfare and preventing cruelty to stray, abandoned or abused dogs and cats in Harris and Montgomery counties of texas. We will focus our efforts on Trap Neuter and Return(TNR) of cats and helping cats and dogs in need. We have established a sanctuary for animals that can't be adopted due to medical condition or age. These activities will be conducted by board members, the volunteers and members of the organization. We will provide shelter, water, food and medical care and rehabilitation for animals in need. Medical care will be performed by local veterinarians and will include but not limited to sterilization, vaccinations, testing for disease, as well any other medical care recommended by the Vet to promote the health of the animal. We focus on animals in need in Harris and Montgomery county Texas. We perform TNR which is common practice in cat rescue. We trap stray animals and spay/neuter/vaccinate and vetted and return them to their location if possible. We also sponsor free cat and dog sterilazation service to residents of the counties. We also offer a voucher system for residents in need who can't afford sterlization services. We also devote our efforts to animals in the 5th ward of Houston which is a low income area. We also offer residents of this area with pet food, vetting and pet care as needed. Our first and foremost goal is to educate and assist area residents who may need help understanding how to better care for their pets and who may need economic assitance to ensure their pets receive essential medical care. We provide residents with vouchers that cover the complete cost of having animals altered and vaccinated against rabies and common diseases. In addition we provide vaccinations and worming in the field free of charge. We also assist residents in placing unwanted puppies born in the area and work with those who own the many chained dogs we observe to provide shelter to protect them from the elements.137186
the National Coalition for History (NCH) advocates on federal legislative and regulatory issues affecting historians, archivists, teachers, researchers, and other stakeholders. Since 1982, the National Coalition for History (formerly the National Coordinating Committee for the Promotion of History) has served as the voice for the historical and archival professions in Washington, DC. The history coalition is a non-profit organization organized under Section 501(c)(3) of the Internal Revenue Code. NCH is solely supported by contributions from its member organizations and the general public.
operation of a commercial paper program for the benefit of california state university (CSU) to enhance the capital financing for projects, equipment, and facilities serving csu.
I am wondering what's wrong with my expression and the solution. thanks

Your expression ([A-Z]{3}) matches 3 uppercase letters and captures them as a group, ie ABC would be matched from "abc ABC abc" (with or without brackets).
To match literal brackets you must escape them:
\([A-Z]{3}\)

Related

DDD - Large aggregate and enforce invariant across aggregates

I'm kind of stuck at modeling this problem in the right way applying Domain Driven Design way. I want to model travelling group in a traveling agency.
We have concepts like passenger, group, and group member in one bounded context. This passenger is a large AR that holds all sorts of information, like name, job, address, bank account, religion, ANYTHING. But not all of them are necessary for all kinds of travels and their invariants differ based on the type of the trip. For example in travel type A, we don't need passengers' phone numbers. In travel type B we do. So when a person goes to create a group to go on travel type B, I will have an invariant on passenger AR to have a valid data for phone.
So basically there are two challenges here: How can I break this huge AR and how should I handle enforcing these conditional invariants? Is it OK if I enforce invariants on passenger AR inside handlers - application service- while creating group AR?
(Besides, the passenger AR and the group AR are in the same bounded context but they have the potential to be separated in the future).
I would say the constraint here should be not on passenger, but on the group.
At the end you may create passengers for different type of travels with or without phone numbers.
The actual constraint should be enforced like a passenger without a phone should not be added to that particular group as a group member.
Regarding the implementation side:
public void addPassengerToGroup(PassengerInformation passenger) {
//original code omitted
this.assertArgumentTrue(passenger.isPhoneInformationProvided(), "Passenger doesn't have contact information.");
this.groupMembers().add(passenger);
}
Somethink like this may solve your problem problem for constraint checks.
There is also some addition explanation for a similar situation:
https://softwareengineering.stackexchange.com/questions/319602/how-to-treat-validation-of-references-between-aggregates
This passenger is a large AR that holds all sorts of information, like name, job, address, bank account, religion, ANYTHING.
Well, to be honest, that sounds wrong as an aggregate. Consider why would you have this aggregate in the first place? What sort of business logic does this aggregate that involves the religion and bank account? or name? or address?
So, in short, this doesn't look like a Passenger aggregate. It looks more like a Customer record on a CRM without following DDD.
The first thing I would suggest is to consider your bounded contexts. I don't know your domain nor the specifics of your application, but most likely, you need bank account information for Finance reasons. So you'll have a Finance Bounded Context with Customers, their bank accounts, the invoices that you sent to them, and so on. You might also have a Bounded Context like Traveling or similar. Here, you might have a Passenger. A passenger could have a CustomerId and a TripId, plus other information, like ContactInformation and so on. You can also have Groups, with a list of Members and each Member could have a PassengerId and other information needed for the group management.
Obviously this is just an example from the limited information I have, but it seems to me, as I said, that a Customer becomes a Passenger when she signs up for a Trip. If the same Customer signs up for another trip, you'll create a new Passenger. There is no reason to reuse the same Passenger aggregate for multiple trips, because, as you said, even if it's the same person going to multiple Trips, the requirements for each are different, so trying to model a single Passenger that will fit all present and future types of Trips is creating an artificial coupling in my opinion.
Also, as I said previously, consider what information do you need on each aggregate. Even if across the whole application you know a lot of things from a single "person", it doesn't mean that you have to store them in a single place. That is the main point of DDD, in my opinion, finding where each piece of information belongs to and put it together with the business logic that needs it.

tools for visualising money flows in a complex company structure

I'm working on a project where we want to visualise money flows in complex company structures. The context is real-estate investment in Berlin, Germany, which faces currently an acute shortage in apartments.
Berlin is a highly attractive market for investors, as the market is still very affordable compared to other European capitals. But as authorities do not support building affordable housing, and don't build themselves, private investors have a relative dominance.
Among private investors, a big part use company networks spread across Europe to aggressively avoid taxes. They use every legal possibility, with mother companies European tax havens like Jersey, Luxemburg and Cyprus. The finance minister of Berlin estimates losses due to tax avoidance by RE investors to 100 to 200 Mio € yearly.
Our project aims to show how these investors work. The goal is to make this highly technical subject understandable for non-specialists, first step to raise public awareness.
We want to show in detail how money flows across company structures that can have 30+ subsidiaires spread across Europe. Here are examples: https://ibb.co/album/kPT6Jv
Example of a complex company structure: the investor Taliesin, Berlin/Jersey
You can see that as an organigram, these structures are more like a puzzle and need a specialist to explain what they mean.
The representation should be dynamic, so that you can see the rents rising from the houses, trickling through the network, ending at the beneficiairies. Ideally, you'd see how much money remains at each station of the network.
A user, or a tenant, could enter the amount of his rent in a field, say 1000 €, and then follow its path through the companies. At the end he'd see that of his rent, 140 € remain in the house for upkeeping, 220 € are used for management costs of the owners, 240 € go to the shell companies and the managers companies, 380 € go the banks as interest rates on the company's loans, 20 € are paid in taxes.
This example is taken from the analysis of the investor Taliesin in Berlin, one of the most agressive tax avoiders, and are actual figures. I co-wrote an article on Taliesin for the Berlin daily Tagesspiegel, 8 oct 2016: https://www.tagesspiegel.de/berlin/share-deals-auf-dem-berliner-immobilienmarkt-wie-investoren-den-kreuzberger-buechertisch-ausbooteten/14658204.html
In our project, "Who do I actually pay rent to", we'll instruct tenants how to research and transmit the data to an analyst-team, who'll then verify and reconstruct the money flow.
Hope this question is not too long.
So back to the actual question:
is there a tool to visualise this type of flows? I've found a couple of blockchain/bitcoin visualisation and ready-mades, like Key lines
do you know developers who could help in finding and adapting the visualisation tools? There will be a couple of other visualisations to do.
The project will be funded and there will be a large chunk of the money reserved to the visualisation tool, as this is main aspect.
Any questions, please ask.
Looking forward for your answers.
Best,
Adrian
Is there a tool to visualise this type of flows? I've found a couple
of blockchain/bitcoin visualisation and ready-mades, like Key lines.
You need a data visualisation app.
In short Yes, this can be built with Python and the use of d3.js to display the data in the way you want.
Python : https://www.python.org/
D3.JS : https://d3js.org/
do you know developers who could help in finding and adapting the
visualisation tools? There will be a couple of other visualisations to
do
Yes, me.

Aggregate Root Choice (for all Football/Soccer fans)

I have been reading StackOverflow for weeks, but I still could not decide whether my DDD Aggregate Root choice is correct. Long story short -- here are the entities. It is about the football/soccer domain:
League, Team and Match
Each Team can participate in one or more Leagues by playing Matches (i.e. English Premier League, UEFA Champions League). Each team has HomeMatches and AwayMatches in a certain League. Each Match has a League, HomeTeam and AwayTeam.
Each League has many Matches.
I think I need to have two repositories -- LeagueRepository where I can get all the matches for a certain league for a certain period. Through this repository I will automatically update the database when a round of matches has been played and I will record the results accordingly.
I also need a TeamRepository, where I can get all the Matches for a certain team in different leagues for different periods of time. This is for statistical purposes, i.e. give me all Liverpool Home Matches in the English Premier League for the last 10 years. Yeah, you guessed right -- it is about betting chances and odds calculations :)
Long story short -- my Domain is the Football/Soccer World. Those of you who follow the sport know those details and what a League, Team and Match is.
Is it OK to have two separate aggregate roots -- League and Team. I can reach a given match through either one of them. Is this OK with the DDD design?
Or should I introduce a new Entity called Sport and make it the sole aggregate root. Then a Sport will have many Leagues and many Teams.
I am using EF code-first approach and I am trying to identify my Repositories and aggregate roots. If you were designing this database, how would you structure those three entities -- League, Team and Match. Of course we are over-simplifying things here.
All your thoughts and comments will be greatly appreciated.
Thanks in advance.
To me, Sport seems like a waste of a concept. If you don't need to model, soccer, baseball, basketball, etc then I imagine the sport model would be mostly empty and a waste of space. If you think of your program in terms of teams and leauges, then that is the two repositories I would stick with. What advantage to a Sport repository do you see other then just having one root?
Three white papers that you should read to better understand how you should go about choosing your aggregates: http://dddcommunity.org/library/vernon_2011/

How to cluster mail subject lines to mail threads?

If I only have the subject lines of mails (no other headers) is there a good algorithm (or package) to cluster them into a set of "related messages"?
A mail with the subject
Our travel plans
is probably related to
Re: Our travel plans and
Re: Re: Our travel plans.
So far so good, but there is also
AW: Our travel plans
Fwd: Our travel plans
Our travel plans (Forward)
I want to cluster all of them together into one thread. Mails with subjects like plans, Re: Our meeting and so on should not be in that thread, of course. I could very well live a hierarchical result -- actually, I kind of like that, because I'd expect that the chance that mails with similar content would get "closer" to each other.
So, i have a lot of ideas: Suffix matching, Prefix trees, Levensthein distances, Q-Gram profiles -- maybe too many. Therefore I ask myself: "Did anyone do this already?"
For sequence comparisons, I use Open Refine (formerly Google Refine) to try out clustering algorithms to fine-tune and identify the algorithm to use. It includes key collision (fingerprint, ngram & double-metaphone) and nearest neighbor (levenshtein distance & prediction by partial matching (PPM)).
https://github.com/OpenRefine/OpenRefine/wiki/Installation-Instructions
Once you have your data imported, just use facets to do your clustering.
Facet > Text facet > Cluster

Functional Specifications vs. Requirements Document

Currently in my comp., there are some changes going on regarding project documentation. There is a LOT of time and effort spent on discussing functional specs vs. requirements doc. However, I don't think anyone here understands the reason why you would use one over the other. Therefore, I don't understand the difference myself.
Can someone shed some light on this matter please? If you have links to articles, blog posts, etc. That would be helpful too.
A Requirements document should specify the requirements from the perspective of the end user.
User requirements document - Wikipedia
A Functional spec is a level lower and starts to define how different parts of the system should function at the System Engineering level:
Functional specification - Wikipedia
Requirements : “what” the application should do [from user's perspective view]
Functional specification: “how” the application function
Technical specification: “how” the function implemented
Requirement:
You must be in Edinburgh by 2pm tomorrow.
Specification:
Travel by car to the airport ... then take a connecting flight to .... then take the tram to the city centre ... then walk to ....
In general it's 'What's the outcome?' versus 'How are we going to do it?'.
Business Requirement:
Implement a computerized system that calculating employees wages with required deductions and additions and pay the amount the employee is actually owed.
Functional Requirements
How many employees in the company and their details
Are they part-time, or full-time or hourly
What is the pay date
What is the deductions like TAX, PF, Community Contributions etc