Soft [practice] first solo work programming assignments

project address

https://github.com/1061413241/AddressBook
time constraints, not learn to build gradle, GitHub has uploaded a warehouse packed with good eclipse addressbook.jarexecutable file, hoping evaluation of the students can use the direct java '-Dfile.encoding=UTF-8' -jar addressbook.jar 1.txt 2.txtcommand.

PSP

PSP2.1 Personal Software Process Stages Estimated time consuming (minutes) The actual time-consuming (minutes)
Planning plan 40 30
· Estimate • Estimate how much time this task requires 40 30
Development Develop 1125 1845
· Analysis · Needs analysis (including learning new technologies) 300 600
· Design Spec Generate design documents 30 50
· Design Review · Design Review 5 5
· Coding Standard · Code specifications (development of appropriate norms for the current development) 20 30
· Design · Specific design 30 30
· Coding · Specific coding 600 1000
· Code Review · Code Review 20 25
· Test · Test (self-test, modify the code, submit modifications) 120 105
Reporting report 50 75
· Test repor · testing report 20 30
· Size Measurement · Computing workload 10 15
· Postmortem & Process Improvement Plan · Hindsight, and propose process improvement plan 20 30
· Total 1215 1950

Table of contents is not precise, but broadly in line with the overall process design. The actual time-consuming and more time-consuming nearly doubled, it is not planned to than forecast. Initially considered nothing more than to learn something new, after experiencing one after another pit, and they knew a pit more than a deep pit.

Problem-solving ideas

C++

1, try violence:

Just saw this assignment, the first thought is to use C ++ implementation. C ++ is a relatively solid language learning, is also used for minor projects, coupled with the questions asked by vs2017. A coincidence, can be described as favorable factors.

  • Location data is not fixed phone number is a factor, first remove the phone number.
  • Remove the extra characters and names, to give pure address string.
  • Remove the keyword address at all levels, appears uncertain factors:
    • Provincial and municipal keywords might be missing, a problem occurs when keywords match the first two stages
  • You can import data matching provincial and municipal administrative

To do it once in accordance with this idea, but I then I thought, since I can import administrative data, why not put it to import an entire dictionary, this idea is very interesting. Then try holding the attitude, really look to find a project on GitHub "cppjieba", but also the C ++ version, which under a lot easy. Do not write their own string matching, and direct the project offers good.

2, hateful cppjieba:

Attach Project Address: https://github.com/yanyiwu/cppjieba

Direct method cppjieba realize word of the address. According to the results of segmentation of the lack of complete information. According to the project description then begin to do:

git clone --depth=10 --branch=master git://github.com/yanyiwu/cppjieba.git
cd cppjieba
mkdir build
cd build
cmake ..
make

The first four easy steps to complete, but the last two steps is the real focus.

  • cmake、make

    Prior I have been using a built-in IDE compiler tools, cmake nothing to understand. After the discovery git can not invoke this command, you go to download one, adding environment variables, cmake perfect execution. Then install make, but always make command error. Check a lot of material,

    " CMake is a cross-platform installation (compilation) tool, you can use a simple sentence to describe the installation for all platforms (compilation). He can output a variety of makefile or project file."

    The key here, I will not execute cmake finished output makefile or project file, so make can not find a corresponding makefile to execute. It should be cmake wrong version, reinstall the version 3.15.3

    This can generate the makefile, it can also make the implementation of the project output file. But vs transferred will be reported in a lot of mistakes. Study for two days, nearly abandoned.

  • Ubuntu

    Before giving up, I think of it a lot of information on the Internet and make cmake are on a Linux system, then tried to go on a virtual machine. Easy to complete the first four steps as usual, behind the system prompts are not installed, apt-get, done all the steps. Input:

    ./demo

    Displayed on the terminal:

    [demo] Cut With HMM
    他/来到/了/网易/杭研/大厦

    I am speechless.

3. Summary:

Violence match may not be the best method, but it is certainly feasible.

cppjieba can really achieve segmentation function, but also for the division of the accuracy of address can be, but for some addresses too detailed division, increased the complexity of the program implementation. Plus still could not solve the problem with VS open, then there is time to carefully study the problem to be solved.

Java

Wasted two days, I have a disagreement on the C ++ heart. They moved to Java.

But still do not succumb to violence to resolve,'d have interesting features. Very early to start learning Java, but front too long, we have just mastered the fur. After the project team would like to make some preparations, we decided to learn to call the API to resolve.

1, Huawei's cloud API:

https://market.huaweicloud.com/product/00301-209781-0--0?ticket=ST-19226-C9KcTiQEvEgeFaAleIAcDEgE-sso

There is no clue on how to use the API, Huawei is the first to find the cloud address word , watching the development of the document four dozen pages, 0 yuan to buy the API, found or will not use, "and then call interface to create APP" What I really do not understand ah, the thought is to use url using the key things, but also to create what APP, and finally nothing.

2, Baidu AI:

http://ai.baidu.com/docs#/NLP-Cpp-SDK/top

B station in terms of how to call the API videos, find up the primary is Baidu AI. It looks pretty simple, though, and functionality I want to achieve nothing, but decided to follow the teaching to practice your hand. Compared to Huawei, Baidu development of the document easier to understand and follow the steps to do step by step, and finally achieved the first API call, as a way to process API calls have some understanding.

3, high moral map API:

https://lbs.amap.com/api/webservice/guide/api/georegeo

After learned to call the API, we started looking for a suitable interface. High moral map interface is very rich, you can return the name of all levels of administrative provinces, cities, counties, etc. address. This will match the first few levels to address violence optimized to simply call an interface to achieve. However, most things to the pit, json data returned by the high moral map, check to be wrong formatting, error causes the program to madness.1568714815018

Desperate .jpg ......

4, Baidu Maps API:

http://lbsyun.baidu.com/index.php?title=webapi/guide/webservice-geocoding-abroad

Compared to the high moral map, Baidu map does not return information Administrative Region at all levels, can only get into the position of latitude and longitude. Only the second call interface Reverse Address Resolution, return subdivisions according to latitude and longitude information. This is the final implementation.

Design and Implementation

As already analyzed the function of the address how divided.

The main classes and methods:

The class name Method name Features
Main main() Implementation file stream operations, call Resolution.addressResolution ()
———— ——————————————— ————————————————
AddressInfo getName(String) Gets Name
setName(String) Set Name
getProvince(String) Gets provinces
setProvince(String) Set provinces
...... Achieve the operation of the various information
———— ——————————————— ————————————————
AddressUtils GetAddressData(String address) API call to get the latitude and longitude data json
GetAddress(String address) Analytical data json Latitude and longitude
GetAddressData2(double lng,double lat) Json calls the API at all levels of address data
GetAddress2(String addressInfo) Resolve all levels of address data in json
addressResolution(String address,char flag) 2 parsed stage (stage 4) Address
———— ——————————————— ————————————————
Resolution addressResolution(String address,char flag) Parse the phone number and name, initialization, call other classes and methods

Regular expression level 2 (level 4) resolve the address:

//5级的后2级
(?<town>[^区]+?区|.+?镇|.+?街道|.+?乡)?(?<village>.*)
//7级的后4级
(?<town>[^区]+区|.+?镇|.+?街道|.+?乡)?(?<village1>.+?街|.+?路|.+?巷)?(?<village2>[\d]+?号|[\d]+.?道)?(?<village3>.*)

Performance Analysis

Key Code Description

1, data parsing json Coordinates:

String addressInfobyJson=GetAddressData(address);
JSONObject dataOfJson = JSONObject.fromObject(addressInfobyJson);

dataOfJson=dataOfJson.getJSONObject("result");
dataOfJson=dataOfJson.getJSONObject("location");
addressInfo.setLng(dataOfJson.getDouble("lng"));//经度
addressInfo.setLat(dataOfJson.getDouble("lat"));//纬度

2, at all levels of address parsing json data:

JSONObject dataOfJson = JSONObject.fromObject(addressInfobyJson);

dataOfJson=dataOfJson.getJSONObject("result");
dataOfJson=dataOfJson.getJSONObject("addressComponent");
addressInfo.setProvince(dataOfJson.getString("province"));//省份
addressInfo.setCity(dataOfJson.getString("city"));//市级
addressInfo.setCounty(dataOfJson.getString("district"));//县级

The most important is to understand the data parsing json json hierarchy, some complex json data will be nested several layers of data, a moment's inattention is "null object". We need to constantly convert object parsing.

Suggest a check json formatting tools: http://www.bejson.com/ structured at a glance.

And exception processing unit test

The main text is processed for information or deletions.

1, the lack of a name or names of non-standard input formats:

3!,北京市东15822153326城区交道口东大街1号北京市东城区人民法院.

2, the lack of phone number:

3!小美,北京市东城区交道口东大街1号北京市东城区人民法院.

3, the lack of address information or address information does not meet the subject requirements:

3!小美,15822153326东城区人民法院.

Summary and harvest

  • A person is really hard to do the project, lack of capacity, lack of experience, step on pit crazy, self-learning ability to find information and problem-solving ability is poor.
  • Preliminary plan is not clear, resulting in learning direction too complicated, too many things to learn in a short time can not digest, not a deep understanding. To learn to stop in time, we have insufficient time to weigh the situation, can not think of all master, to seize the key, the maximum possible savings time.
  • Master the test method too, debug capability is not strong.
  • And chiefs still have a orz

Guess you like

Origin www.cnblogs.com/azeLibertas/p/11537373.html